class Monster def react(action) :roar end end
class Komoju < Monster def react(action) if action == :pat return :purr end super end end
# Get characters of string 'abc'.chars => ["a", "b", "c"]
# Get character codes of string 'abc'.chars.map(&:ord) => [97, 98, 99]
| Komoju.new.react(:pat) => :purr
Komoju.new.react(:poke) => :roar
Komoju.superclass => Monster
# Modules module LaserWeapon def shoot_laser 'Pew pew pew!' end end
class Komoju include LaserWeapon end
Komoju.new.shoot_laser => 'Pew pew pew!'
|