[erlang-questions] is there "return" in Erlang.
Mon Feb 28 15:09:00 CET 2011
On 2011-02-28, at 14:59 , Attila Rajmund Nohl wrote:
> 2011/2/28, Jachym Holecek <freza@REDACTED>:
>> And about return in general -- in Erlang (and other functional languages)
>> program is composed of expressions that get evaluated to values, there are
>> no statements. This is the reason why you do things like:
>> A = case (X rem 2) of
>> 0 ->
>> 1 ->
>> which quite annoyingly you can't do in C.
> I might misunderstand something, but
> A = (X % 2 == 0) ? even : odd;
> can be done in C …
Yes, his case was overly simplistic and thus easy to reproduce with a ternary. But a ternary is not going to scale very far (not without making the next person having to maintain your code go postal) whereas a case can grow quite a bit (in number of patterns, for instance)
More information about the erlang-questions