[erlang-questions] Inline If

Henning Diedrich hd2010@REDACTED
Sun May 9 00:37:54 CEST 2010


Thanks Zoltan,

so the answer would be

-define(ASSERT(TEST,TRUE,FALSE), case TEST of true -> TRUE; false -> 
FALSE end).

This seems to imply that even just wanting to use such construct is not 
a common thing in Erlang.

Is there a reason for that in the nature of FP or Erlang?

Thanks,
Henning


Zoltan Lajos Kis wrote:
> On 5/9/2010 12:00 AM, Henning Diedrich wrote:
>> Is there a common Erlang way to do stuff like C++:
>>
>>    a ? b : c;
>>
>> The list comprehension
>>
>>    [X || X <- [B,C], A ]
>>
>> ?
>>
>> Thanks,
>> Henning
>>
>
> You can define a function or macro for this purpose; see "assert" 
> discussed in this thread: Ternary operator used as assert
> http://www.erlang.org/cgi-bin/ezmlm-cgi?4:sss:48575:200912:jchpnnbpampjdbbfpigm 
>
>
> Regards,
> Zoltan.
>


More information about the erlang-questions mailing list