[erlang-questions] using catch - getting error

Dmitry Vasiliev dima@REDACTED
Sat Jun 26 00:46:51 CEST 2010


On 26.06.2010 2:16, Wes James wrote:
> If the key exists, then put it in Val and return Val, if the key does
> not exist, catch the error and set Val to 0.
> 
> How should this be done?

Consider to use proplists (http://www.erlang.org/doc/man/proplists.html)
module for {Key, Value} lists. It seems proplists:get_value/3 do what
you need.

-- 
Dmitry Vasiliev <dima at hlabs.org>
http://hlabs.org
http://twitter.com/hdima
http://erlport.org


More information about the erlang-questions mailing list