I started off this morning trying to work out what the 'when' statement is used for in erlang. I know the below example is wrong:
do_larger() ->
io:format("Larger~n").
do_smaller() ->
io:format("Smaller~n").
when_version(Size) ->
when Size > 10 -> do_larger(),
when Size < 10 -> do_smaller().
I decided to look at its implementation in Haskell to see if this would help and I ended up getting even more confused.
Is anyone able to point me at a tutorial (or explain to me) what the when statement is used for and how it's used in haskell and/ or erlang?