Skip to content

Instantly share code, notes, and snippets.

@hackervera
Created September 16, 2010 12:47
Show Gist options
  • Select an option

  • Save hackervera/582360 to your computer and use it in GitHub Desktop.

Select an option

Save hackervera/582360 to your computer and use it in GitHub Desktop.
class Child
@@name = "baby"
def name
return @@name
end
end
class OtherChild
@@name = "baby"
def name
return @@name
end
end
class Adult < Child
def initialize
@@name = "Sleeper Agent!"
end
end
class Main
@babies = [];
def self.cry
@babies.each { |baby|
puts baby.name
}
end
def self.addBaby(babe)
@babies << babe
end
end
10.times {
if rand*10 < 3
Main.addBaby Child.new
end
Main.addBaby OtherChild.new
}
Main.cry
otherDude = Adult.new
puts "\n\n"
Main.cry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment