Aurimas Aurimas - 5 months ago 9
Ruby Question

Ruby equivalend to Coffeescript shortened version of shorthand if operator?

How can you do this in Ruby?

In coffeescript you can do

name = a ? "bear"

Answer

Boolean or:

name = a || "bear"

To be precise, the following is an exact equivalent (there is no undefined in ruby):

name = a.nil? ? 'bear' : a
Comments