Created
May 5, 2010 17:53
-
-
Save dougbarth/391174 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
def foo=(bar) | |
puts "in foo=" | |
bar*1.5 | |
end | |
def original_code | |
puts "The original quiz code sets a local var, and does not call the method" | |
puts("return val: #{foo = 8}") | |
puts("local variables: " + local_variables.inspect) | |
end | |
def modified_code | |
puts "\nSwitching to self.foo = 8 calls the method" | |
puts("return val: #{self.foo = 8}") | |
puts("local variables: " + local_variables.inspect) | |
end | |
original_code | |
modified_code | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment