[MacRuby-devel] [MacRuby] #112: NSNumber should behave consistently regardless of how it is accessed
MacRuby
ruby-noreply at macosforge.org
Sat Aug 30 13:29:40 PDT 2008
#112: NSNumber should behave consistently regardless of how it is accessed
-------------------------------------+--------------------------------------
Reporter: jordan.breeding at mac.com | Owner: lsansonetti at apple.com
Type: defect | Status: new
Priority: blocker | Milestone: MacRuby 0.4
Component: MacRuby | Resolution:
Keywords: |
-------------------------------------+--------------------------------------
Changes (by lsansonetti at apple.com):
* milestone: => MacRuby 0.4
Comment:
The problem here is that NSNumber does not implement the Numeric interface
yet, because it's defined on Numeric itself.
{{{
$ macirb
>> 1.class.ancestors
=> [Fixnum, Precision, Integer, Precision, Numeric, Comparable, NSNumber,
NSValue, NSObject, Kernel]
>> NSNumber.numberWithInt(42).class.ancestors
=> [NSCFNumber, NSNumber, NSValue, NSObject, Kernel]
>> NSNumber.numberWithInt(42) + 1
NoMethodError: undefined method `+' for #<NSCFNumber:0x13a49b0>
from (irb):3
from /usr/local/bin/macirb:12:in `<main>'
}}}
Ideally we should reimplement Numeric on top of NSNumber as we did for
String/Array/Hash and change MacRuby to always emit NSNumbers (or
subclasses) for fixnums instead of special constants.
--
Ticket URL: <http://www.macruby.org/trac/ticket/112#comment:1>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list