RailsCasts Pro episodes are now free!

Learn more or hide this

Douglas Drumond's Profile

GitHub User: drumond19

Comments by Douglas Drumond


In fact, a ||= "something" is equivalent to a = a || "something"
What does this mean?
a = a || "something" -> left operand in a || "something" isn't defined, evaluates to nil, which is false, then right operand needs to be evaluated as well, so assigning a value.

That's an idiom that came from C language. Try that in irb and you see there's no error at all.