3 ms·
this is not true: ||= expands to @variable = @variable || @other_variable I am not sure if semantics of defined-or-assign operator changed in recent rubie
by riffraff 15y ago
this is not true:
||= expands to @variable = @variable || @other_variable
I am not sure if semantics of defined-or-assign operator changed in recent rubies, but ||= used to expand to
foo or foo = bar.
Which is different in some edge cases, e.g.
>> a= Hash.new(0)
=> {}
>> a[:key] ||= :v
=> 0
>> a
=> {}
>> a[:key] = a[:key] || :v
=> 0
>> a
=> {:key=>0}
- halostatue 15y agoAs far as I know, this behaviour is still the same; changing it would be a breaking change for those edge cases.