Skip to content

Instantly share code, notes, and snippets.

@danielpclark
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save danielpclark/2d2866700a75cba436da to your computer and use it in GitHub Desktop.

Select an option

Save danielpclark/2d2866700a75cba436da to your computer and use it in GitHub Desktop.
class Cat
def self.all
ObjectSpace.each_object(self).to_a
end
end
class Animal
attr_accessor :all
def initialize
@all = []
end
end
animals = Animal.new
3.times do
animals.all << Cat.new
end
Cat.all.any? {|i| animals.all.include? i}
Cat.all.all? {|i| animals.all.include? i}
animals.all.any? {|i| Cat.all.include? i}
animals.all.all? {|i| Cat.all.include? i}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment