For this statement:
@speaks_english ||=3D @name.size > 6
does it mean something like below?
if @name.size > 6
=A0 =A0@speaks_english ||=3D @name.size
end
As an addition to the other replies to your question, there is a useful
post on this by Rick DeNatale, see below.
Rick DeNatale also notes that x &&=3D y behaves similarly - it means:
x && (x =3D y)
I've emphasized the last sentence below because although
I know the real meaning of ||=3D the point that it preserves
the short-circuit nature hadn't occurred to me, and I think
it's a useful help to remembering exactly what ||=3D does.
http://talklikeaduck.denhaven2.com/2008/04/26/x-y-redux
A while back there was quite a thread on the Ruby-lang mailing list
about the real semantics of the expression.
a[x] ||=3D some_value
In many books and articles on Ruby the form:
a <op>=3D b
Where <op> is an operator like + is described as syntactic sugar for:
a =3D a <op> b
While this is true in most cases, it isn't true if the operator is ||.
...
Matz explains that the real expansion of x ||=3D y is:
x || (x =3D y)
...
Since || is a =91short-circuit=92 boolean operator,
the left hand operand expression is only evaluated
if the right hand operand expression evaluates
to a logically false value, i.e. either nil or false.
The way that Matz included ||=3D as an assignment operator
makes perfect sense to me. *** The ||=3D assignment operator
reserves the short-circuit nature of ||. ***