# ObjectSpace.each\_object unexpected results

**URL:** <https://www.ruby-forum.com/t/objectspace-each-object-unexpected-results/185186>\
**Category:** IronRuby\
**Created:** [March 15, 2010, 6:40pm UTC](https://www.ruby-forum.com/t/objectspace-each-object-unexpected-results/185186 "2010-03-15T18:40:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Closson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f05b48/32.png) [@Matthew\_Closson](https://www.ruby-forum.com/u/Matthew_Closson)\
**Post date:** [March 15, 2010, 6:40pm UTC](https://www.ruby-forum.com/t/objectspace-each-object-unexpected-results/185186/1 "2010-03-15T18:40:37Z")

</div>

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 0.9.5.0\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  
end

def introduce  
puts “Hi, I’m #{@first} #{@last}”  
end  
end

john = Human.new(‘John’, ‘Doe’)  
ObjectSpace.each\_object(Human) {|x| x.introduce}

* * *

Results from MRI 1.9.1  
Hi, I’m John D.
