[MacRuby-devel] [MacRuby] #297: ObjectSpace.each_object returns Class and Module objects when it shouldn't

MacRuby ruby-noreply at macosforge.org
Sat Aug 8 18:58:43 PDT 2009


#297: ObjectSpace.each_object returns Class and Module objects when it shouldn't
--------------------------------+-------------------------------------------
 Reporter:  ned@…               |       Owner:  lsansonetti@…        
     Type:  defect              |      Status:  new                  
 Priority:  minor               |   Milestone:  MacRuby 0.5          
Component:  MacRuby             |    Keywords:                       
--------------------------------+-------------------------------------------

Comment(by dev@…):

 in 0.5 this is still there, but with Module instances which are returned
 as Class instances

 {{{
 $ macruby -e 'p ObjectSpace.each_object(Class).reject { |o|
 o.class.ancestors.include? Class }.map  { |o| o.class }.uniq'
 [Module]
 }}}

 more general:

 {{{
 $ macruby -e 'p(
 [Object,Module,Class,String,Array,Hash,Integer,Regexp,Range].map { |c|
 ObjectSpace.each_object(c).reject { |o| o.class.ancestors.include? c }.map
 { |o| o.class }.uniq.map { |o| {c => o} } }.select { |a| a.size >
 0}.flatten)'
 [{Class=>Module}, {NSMutableString=>NSString}, {NSMutableArray=>NSArray}]
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/297#comment:4>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list