Ruby equivalent of Groovy's Elvis (?:) operator? Ruby equivalent of Groovy's Elvis (?:) operator? ruby ruby

Ruby equivalent of Groovy's Elvis (?:) operator?


Never mind :-) I just found the answer myself after finding out the name of the operator.

From here:

PARAM = ARGV[0] || 'default'

(Must be 'cause I'm juggling 4 languages right now so I forgot I could do that in the first place.)


Possible since Ruby 2.3.

dog&.owner&.phone


Isn't PARAM = ARGV[0] ? ARGV[0] : 'default' the same as PARAM = (ARGV[0] || 'default') ?