I know I can live without it, but the question’s been bugging me.
Is there a Ruby idiom that’s equivalent to Groovy’s Elvis operator (?:)?
Essentially, I want to be able to shorten this
PARAM = ARGV[0] ? ARGV[0] : 'default'
Or equivalently
PARAM = 'default' unless PARAM = ARGV[0]
Into something like this
PARAM = ARGV[0] ?: 'default'
Never mind 🙂 I just found the answer myself after finding out the name of the operator.
From here:
(Must be ’cause I’m juggling 4 languages right now so I forgot I could do that in the first place.)