From: luke gruber Date: 2011-08-01T06:29:06+09:00 Subject: system stack error in ObjectSpace.each_object Hey guys, I'm just starting to mess around with metaprogramming in Ruby, so I was just having a bit of fun and trying to make a script that would allow for creating a 'leader' object in a class, and then when that object is sent a message, all other objects of some subordinate class would respond to the same message. So the script I wrote is here: https://github.com/luke-gru/lemmings/blob/master/leader.rb On line 52, I ran into this issue: def get_other_objects(subord_class) obj_ary = [] ObjectSpace.each_object(subord_class) do |o| obj_ary.push(o) unless o.leader # here end obj_ary end If I don't have the 'unless o.leader' expression modifier, it pushes like a million of the 'leader' objects and raises a SystemStackError. I have no idea why, and would really appreciate an answer. Thanks, -Luke -- Posted via http://www.ruby-forum.com/.