[erlang-questions] checking for unbound?
Sun Nov 21 11:30:29 CET 2010
From your example, I think what you're looking for is pattern matching...
case mnesia:dirty_index_read(myTable, value, indexField) of
 -> do something; % nothing was returned
[E] -> do something with E; % 1 item was returned
[H|T] -> do something with H and T % more than 1 item was returned
- Edmond -
On Sun, 21 Nov 2010 01:18:03 +1100, Andy Kriger <>
> Is there a way to test if a variable is unbound?
> I thought I could do something clever like...
> [E|EL] = mnesia:dirty_index_read(myTable, value, indexField),
> if <E is unbound> -> do something; % nothing was returned
> length(EL) > 0 -> do something; % more than 1 item was returned
> <E matches pattern> -> do something; % a match was returned
> true -> do something % whatever is left
> But I don't see a way to make the first test.
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the erlang-questions