Hi,

In message "[ruby-talk:15810] Re: is it possible to dynamically coerce objects types in Ruby?"
    on 01/05/28, Mirian Crzig Lennox <mirian / cosmic.com> writes:

|This is great!  However, I notice that when I try to use MyClass
|objects in addition, I get these errors:
|
|	m + 4
|	ERR: (eval):1: undefined method `+' for #<MyClass:0x401787a0>
|
|	4 + m
|	ERR: (eval):1:in `+': MyClass can't be coerced into Fixnum
|
|I'm not exactly sure what I need to do to make this work.

If you reallly want MyClass to be integer that much, either

 (a) define all numeric related operators/methods to MyClass.

 (b) delegate every message to the (internal) integer.

 (c) implement coerce mechanism by defining 'coerce' method (see p.354
     of the Pickaxe book).

Hope this helps.

							matz.