Skip to content

Instantly share code, notes, and snippets.

@dougbarth
Created May 5, 2010 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dougbarth/391174 to your computer and use it in GitHub Desktop.
Save dougbarth/391174 to your computer and use it in GitHub Desktop.
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