Based on what I have read about the ||=
operator in Ruby, I would expect that the following line of code should assign the variable a
(an as yet unassigned variable) in the example to 5
.
a |= "-----n-".index /n/
Just evaluating "-----n-".index /n/
on its own gives you 5
.
However, after executing the above line, a
is set to true
.
The following sets b
to false
, whereas I would expect that b
should be nil
:
b |= "-----n-".index /o/
Can you please explain this to me?