On 6/14/10, Rein Henrichs <reinh / reinh.com> wrote: > On 2010-06-14 14:48:36 -0700, Roger Pack said: > >> I read this once: >> >> Operator ||= can be shorthand for code like: >> x = "(some fallback value)" unless respond_to? :x or x >> >> How would that look like exactly, in shorthand, any guesses? >> -r > > The expression: > > a ||= b > > is equivalent to: > > a || a = b > > in most cases. To be pedantic, it is actually: > > (defined?(a) && a) || a = b Except if there's a method named a, defined?(a) returns "method", so this still isn't exactly equivalent. Ruby is tricksy.