Skip to content

Instantly share code, notes, and snippets.

@jacegu
Created December 3, 2010 14:47
Show Gist options
  • Save jacegu/727047 to your computer and use it in GitHub Desktop.
Save jacegu/727047 to your computer and use it in GitHub Desktop.
A little example about open Classes in Ruby
class Dog
def bark
puts 'guau'
end
end
def try_my_dog
dog = Dog.new
dog.bark
begin
dog.purr
rescue NoMethodError
puts "dog doesn't have a method called 'purr'"
end
end
try_my_dog
class Dog
def purr
puts 'purr, purr, purr'
end
end
try_my_dog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment