Question about using case statements
James Aimonetti
james.aimonetti@REDACTED
Sat Aug 28 01:11:13 CEST 2010
Hey list,
Wondered what the list thought of this usage of case statements: I
have a file path and a proplist with some values, one of which tells
me what to do with the file. I want to be sure the file exists before
I do something with the file but didn't want to get too deep into
nested case statements, so I have something like this ->
...
Prop = get_proplist_from_somwhere(),
File = get_file_from_somewhere(),
case filelib:is_regular(File) andalso get_value(key, Prop) of
false ->
handle_missing_file_error(File);
specific_value_1 ->
do_specific_value_1_action(File, Prop);
...
_Val ->
io:format("Unhandled file action value ~p~n", [_Val]) % to be
removed after testing
end,
...
Is this common / acceptable use of the andalso short-circuit boolean?
Thanks,
James
More information about the erlang-questions
mailing list