Comment

Comment by Natsu

For anyone who didn't know what if expressions look like in Erlang and had to look it up, apparently they use a series of "guard sequences" and the first one to be true determines the return value. If none of the sequences is true, it creates an error. There's no "else" keyword, so you have to use true as a substitute for it like this:

  is_greater_than(X, Y) ->
    if
        X>Y ->
            true;
        true -> % works as an 'else' branch
            false
    end
(Code from http://www.erlang.org/doc/reference_manual/expressions.html section 7.7)

See also: http://erlang.org/pipermail/erlang-questions/2009-January/04...

parent Natsu 14 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton