How come (a_method || :other) returns :other only when assigning to a var called a_method?
- by Paul Annesley
Given the following method:
def some_method
:value
end
The following statements work as I would expect:
some_method || :other
# => :value
x = some_method || :other
# => :value
But the behaviour of the following statement perplexes me:
some_method = some_method || :other
# => :other
It creates a local variable called some_method…