Created
April 8, 2010 23:54
-
-
Save captainpete/360695 to your computer and use it in GitHub Desktop.
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
# At first glance, this doesn't seem so useful. | |
def a | |
def b | |
'you called b' | |
end | |
'b is now defined' | |
end | |
# > b | |
# NameError: undefined local variable or method `b'... | |
# > a | |
# => "b is now defined" | |
# > b | |
# => "you called b" | |
# but taken another way... | |
def enter_building | |
def enter_building | |
"enter building" | |
end | |
# method is now redefined for subsequent calls | |
"open roller door, " + enter_building | |
end | |
# > enter_building | |
# => "open roller door, enter building" | |
# > enter_building | |
# => "enter building" | |
# > enter_building | |
# => "enter building" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment