Is there a way to get all the objects that are of a certain class in Ruby?
To clarify:
class Pokemon
end
pikatchu = Pokemon.new
charmander = Pokemon.new
So, is there a way I could somehow retrieve references those two objects (pikatchu
and charmander
)?
I actually thought of shoving it all into a class array via initialize, but that could potentially grow big, and I am assuming there might be a native Ruby approach to it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…