[Ironruby-core] ConvertTo vs Cast

Wayne Kelly w.kelly at qut.edu.au
Tue Feb 5 19:03:45 EST 2008


Hi Peter,

Yes, you are right, sorry - somehow I missed reading the very last case in our fix_plus implementation :(

________________________________
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Peter Bacon Darwin
Sent: Wednesday, 6 February 2008 12:16 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] ConvertTo vs Cast

What about this though?

class D
  def +(other)
    45
  end
  def coerce(other)
    [self,self]
  end
end

3 + D.new
=> 45


In Ruby 1.8.6:

Fixnum.instance_method("+').bind(3.0)

produces:

'bind': bind argument must be an instance of Fixnum (TypeError)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20080206/3636870d/attachment.html 


More information about the Ironruby-core mailing list