analog of C condition?truebranch:falsebranch operator ???

Matthias Lang matthias@REDACTED
Mon Apr 17 12:23:07 CEST 2006


Gaspar Chilingarov writes:

 > Are there any construct like C ?: operator in Erlang?

Sure, except in Erlang it's the ?_ operator, and you need to define it:

  -define(_(C,A,B), case C of true -> A; _ -> B end).

you use it like this:

  ?_(condition, true_branch, false_branch)

Beautiful, isn't it?

Matthias



More information about the erlang-questions mailing list