[Ironruby-core] ObjectSpace.each_object unexpected results

Matthew Closson matthew.closson at gmail.com
Mon Mar 15 13:36:55 EDT 2010

I was running an example from page 176 of IronRuby Unleashed and I got an
unexpected error.
I added a class definition for Human to make the example run.  In MRI 1.9.1
the code works as expected.
Thanks for any insight, and I'm always willing to test patches.

             -Matt Closson-

>C:\Program Files\IronRuby\bin\ir -profile -trace test.rb
test.rb:13:in `each_object': each_object only supported for objects of type
Class or Module (RuntimeError)
from test.rb:13

>Exit code: 1

class Human
  def initialize(first_name, last_name)
    @first = first_name
    @last = last_name

  def introduce
    puts "Hi, I'm #{@first} #{@last}"

john = Human.new('John', 'Doe')
ObjectSpace.each_object(Human) {|x| x.introduce}


Results from MRI 1.9.1
Hi, I'm John Doe
>Exit code: 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100315/66399faa/attachment.html>

More information about the Ironruby-core mailing list