[erlang-questions] lists:keyfind as an alternative to lists:keysearch

Thomas Lindgren thomasl_erlang@REDACTED
Wed Jan 21 13:54:14 CET 2009


--- On Wed, 1/21/09, Bengt Kleberg <bengt.kleberg@REDACTED> wrote:
> Rickard has my support. I, too, find mixing boolean and
> none boolean
> return values surprising.
> 
> Perhaps {} (empty tuple) is an appropriate return value if
> nothing is
> found?
> 

Personally, I nearly always wrap lookup return values as

   {found, Value} | not_found

Which has served me quite well so far.

(And not that it really matters for this discussion, but returning an empty tuple allocates a tuple header on the heap :-)

Best,
Thomas



      



More information about the erlang-questions mailing list