[MacRuby] #297: ObjectSpace.each_object returns Class and Module objects when it shouldn't
MacRuby
ruby-noreply at macosforge.org
Sat Dec 4 13:02:21 PST 2010
#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: #reduction
--------------------------------+-------------------------------------------
Changes (by eloy.de.enige@…):
* keywords: => #reduction
Comment:
On current trunk:
Original:
{{{
% macruby -e "p
ObjectSpace.each_object(String).reject{|o|o.class.ancestors.include?(String)}.map{|o|o.class}.uniq"
[]
}}}
Last two:
{{{
% macruby -e 'p ObjectSpace.each_object(Class).reject { |o|
o.class.ancestors.include? Class }.map { |o| o.class }.uniq'
[Module]
% 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}]
}}}
Not sure how important the last cases are…
--
Ticket URL: <http://www.macruby.org/trac/ticket/297#comment:5>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list