Erlang Notes

erlang caveats
Login

erlang caveats

  1. You probably want andalso, not and.

You probably want andalso, not and.

Consider:

1> 1 > 2 and 3 > 4.
* 1:13: syntax error before: '>'
1> erlang:display(this) or erlang:display(that).
this
that
true
2> 1 > 2 andalso 3 > 4.
false
3> erlang:display(this) orelse erlang:display(that).
this
true

andalso and orelse have the precedence and the short-circuiting that you expect from other languages. They can also be used tail-recursively.