3 ms·
You are confusing setters with the assignment evaluation. Setters are just normal methods. ?> def you_are_wrong=(a) ?> a * 2 >> end => :you_a
by byroot 4y ago
You are confusing setters with the assignment evaluation. Setters are just normal methods.
?> def you_are_wrong=(a)
?> a * 2
>> end
=> :you_are_wrong=
>> send(:you_are_wrong=, 24)
=> 48
However yes, the `foo.bar = 24` expressions translates to `(foo.send(:bar=, 24); 24)`.
The reason is so that `foo = bar.baz = 12` works as you expects, it's absolutely not some kind of cruft or black magic.