Question about using case statements

James Aimonetti <>
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 ->
  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

Is this common / acceptable use of the andalso short-circuit boolean?



More information about the erlang-questions mailing list