Created
October 29, 2012 17:27
-
-
Save octosteve/3975053 to your computer and use it in GitHub Desktop.
Conventional way to add methods to a class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cart | |
def confirm | |
"Your order is being processed" | |
end | |
end | |
cart = Cart.new | |
# then reopen the class | |
class Cart | |
def deny | |
"Your order has been denied!" | |
end | |
end | |
cart.deny | |
#=> "Your order has been denied!" | |
next_cart = Cart.new | |
next_cart.deny | |
#=> "Your order has been denied!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment