Q:

Shorthand for x ? x : y

Is there a shorthand for x ? x : y? A relatively tame example:
def find_or_create_by_name(name)
    self.find_by_name(name) ? self.find_by_name(name) : self.create(name)
end

Of course I could do something like
def find_or_create_by_name(name)
    x = self.find_by_name(name)
    x ? x : self.create(name)
end

but then I'm starting to lose the space I've saved with the ternary operator in the first place. (and if I use a full if statement, the same redundancy would occur.

A:

you can just use || operator:
def find_or_create_by_name(name)
  find_by_name(name) || create(name)
end

