Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Drink
- def sip
- puts "You drank with caution"
- end
- end
- class Coffee < Drink
- def method_missing(method_name, *args, &block)
- if method_name == :gulp
- puts "Please don't gulp your coffee!"
- sip
- else
- super
- # this will do the normal thing of raising an exception that the method wasn't found
- end
- end
- end
- class Water < Drink
- def gulp
- puts "You drank the water with reckless abandon!"
- end
- end
Add Comment
Please, Sign In to add comment