[MacRuby-devel] [MacRuby] #726: Methods added to String do not get added to all strings

MacRuby ruby-noreply at macosforge.org
Fri May 21 11:18:06 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:  MacRuby 0.6          
Component:  MacRuby              |    Keywords:                       
---------------------------------+------------------------------------------
 Methods added to the string class are not being added to the string
 returned from NSMutableString. I've also seen this with stringValue from
 NSTextFieldCell.

 The following will generate an error, even though the classes of the two
 objects are both 'String'.

 I'm not sure if this occurs with other open classes.

 {{{
 class String
   def cook
     puts 'Bacon!'
   end

   def to_mutable_attributed_string
     NSMutableAttributedString.alloc.initWithString( self )
   end
 end

 base_string = 'breakfast'

 puts base_string.class
 base_string.cook

 mutable = base_string.to_mutable_attributed_string

 puts mutable.string.class
 mutable.string.cook

 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/726>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list