Quirky Privates
Just one of those little Ruby language quirks. Normally, you have to use
the implicit receiver when sending a private
message. This can be
demonstrated as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
However, this is not true when sending a message that ends in =
. In
this case you must use the explicit receiver self
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
In fact, without the explicit reciever self
when sending a private
message ending in =
, you will instead create a local variable with
that name. This is then the reference point for the rest of the method
body.