ObjectSpace.each_object unexpected results

I was running an example from page 176 of IronRuby Unleashed and I got
unexpected error.
I added a class definition for Human to make the example run. In MRI
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
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 D.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs