Re:Ruby Tips, Part 5
by riffraff on Wednesday April 23, 2014 @03:55AM
(#7632717)
I didn't mean that it is "x = x || y", I meant "it's completely ad hoc".
For example, if you try "x || x = y" you will get an exception if x is not defined, but "x ||= y" will work fine. The same is true of constants "X || X = 1" will explode while "X ||= 1" will work fine.
For example, if you try "x || x = y" you will get an exception if x is not defined, but "x ||= y" will work fine. The same is true of constants "X || X = 1" will explode while "X ||= 1" will work fine.