3 ms·
I would say that languages where "if" can be used as expression provide a different (perhaps better) syntax for the same ternary operator. a = if x then y
by IlliOnato 3y ago
I would say that languages where "if" can be used as expression provide a different (perhaps better) syntax for the same ternary operator.
a = if x then y else z
is just a more verbose version of
a = x ? y : z;
Raku uses yet another form of the same operator:
a = x ?? y :: z;
Syntactic sugar :-)
- lizmat 3y agoIt's actually a = x ?? y !! z And that's because a single : is used for many other semantics in the Raku Programming Language. And ?? and !! standout better in code. https://docs.raku.org/language/operators#infix_??_ https://docs.raku.org/language/operators#infix_??_!!
- IlliOnato 3y agoYou are right, of course. Sorry! "Colon belongs to Larry" :-) I think I made this mistake because :: was used in one of the drafts for Perl 6, but the final specification uses !!