[MacRuby-devel] [MacRuby] #726: Methods added to String do not get added to all strings
MacRuby
ruby-noreply at macosforge.org
Tue May 25 14:50:43 PDT 2010
#726: Methods added to String do not get added to all strings
---------------------------------+------------------------------------------
Reporter: dylan@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
---------------------------------+------------------------------------------
Changes (by martinlagardette@…):
* milestone: MacRuby 0.6 =>
Comment:
Hi!
This is because of the way strings are implemented within MacRuby. If you
look at the result of this command:
{{{
macruby -e 'p String.ancestors'
[String, NSMutableString, NSString, Comparable, NSObject, Kernel]
}}}
You can see that `String` is defined on top of of `NSMutableString`, which
is why defining a method on `String` won't define it on `NSMutableString`
or `NSString`.
In your example, if you replace "`class String`" by "`class NSString`",
then it will work as expected:
{{{
String
Bacon!
String
Bacon!
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/726#comment:1>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list