Hi,
In message "[ruby-talk:15818] Re: is it possible to dynamically coerce objects types in Ruby?"
on 01/05/28, Mirian Crzig Lennox <mirian / cosmic.com> writes:
|coerce is pretty nice, thank you. It seems that when I use coerce, I
|still have to define operators where MyClass is the left hand side of
|the expression;
|e.g.,
| 4 + myObject # This is handled automatically by myObject's coerce
|but
| myObject + 4 # fails if myObject's class doesn't define '+'.
|
|Is this correct?
Yes. You have to pay the cost to join Numeric family.
matz.