[MacRuby-devel] [MacRuby] #671: MacRuby developers can't know if their arrays are mutable or immutable

MacRuby ruby-noreply at macosforge.org
Sun May 2 16:09:51 PDT 2010


#671: MacRuby developers can't know if their arrays are mutable or immutable
-------------------------------------+--------------------------------------
 Reporter:  mattaimonetti@…          |       Owner:  lsansonetti@…        
     Type:  defect                   |      Status:  new                  
 Priority:  blocker                  |   Milestone:  MacRuby 0.6          
Component:  MacRuby                  |    Keywords:                       
-------------------------------------+--------------------------------------
 The following code will raise an exception:

 {{{
 [1,2,3].copy << 4
 }}}

 The reason why is because Array implements NSCopy and calling #copy on a
 mutable array will return an immutable version. So everything is normal,
 the only problem is that since the 0.6 Array rewrite, one can't figure out
 if his array is mutable or not:


 {{{
 NSArray.arrayWithObjects('terrans', 'zerg', 'protoss', nil).class
  => Array
 NSMutableArray.arrayWithObjects('terrans', 'zerg', 'protoss', nil).class
  => Array
 NSMutableArray.arrayWithObjects('terrans', 'zerg', 'protoss',
 nil).copy.class
  => Array
 [1,2,3].class
  => Array
 ruby-1.9.1-p243 > [1,2,3].copy.class
  => Array
 ruby-1.9.1-p243 > [1,2,3].copy.frozen?
  => false
 }}}

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



More information about the MacRuby-devel mailing list