case A of true -> case B of true -> case C of true -> ok; false -> error end; false -> error end; false -> error end.
如果判断很多的话, 那么代码可读性就太差了
if
1 2 3 4 5 6
if A -> ok; B -> ok; C -> ok; true -> error end
虽然代码看起来规整了,但是变量A,B,C必须先算出结果 性能是个问题
catch-1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
test() -> catch test_f1(). test_f1() -> case A of false -> throw(error); _ -> ok end, case B of false -> throw(error); _ -> ok end, case C of false -> throw(error); _ -> ok end.
test() -> ?CATCH( begin case A of false -> ?RETURN(error); _ -> ok end, case B of false -> ?RETURN(error); _ -> ok end, case C of false -> ?RETURN(error); _ -> ok end end).