By bloid
via codecommit.com
Published: Jul 07 2008 / 10:35
Groovy has an interesting shortening of the ternary operator that it rather fancifully titles “the Elvis Operator“. This operator is hardly unique to Groovy - C# has had it since 2.0 in the form of the Null Coalescing Operator - but that doesn’t mean that it is not a language feature worth learning from. Surprisingly (for a C-derivative language), Scala entirely lacks any sort of ternary operator. However, the language syntax is more than flexible enough to implement something similar without ever having to dip into the compiler.
SaveShareSend
Tags: other languages
Comments
shemnon replied ago:
Getting the words 'Elvis' and 'impersonating' into a DZone article and actually having them be relevant instead of gratuitous deserves an up vote. Now if there was only some way to get Vegas involved...
daniel replied ago:
LOL I hadn't thought of that. Now, *realizing* that the words 'Elvis' and 'impersonating' have alternative application outside of CompSci deserves an up-vote in and of itself. :-)
Voters For This Link (12)
Voters Against This Link (0)