Skip to content

Instantly share code, notes, and snippets.

@danielhopkins
Created January 24, 2012 04:19
Show Gist options
  • Save danielhopkins/1667793 to your computer and use it in GitHub Desktop.
Save danielhopkins/1667793 to your computer and use it in GitHub Desktop.
But why?
class TryIt
def []=(k,v) return "I'm a return value, if I'm not returned where do I go?" end
end
t = TryIt.new
puts(t['blah'] = "It would be slightly surprising if I were returned, right?")
#=> "It would be slightly surprising if I were returned, right?"
class TryIt
def []=(k,v)
raise 'look at the stack'
return "I'm a return value, if I'm not returned where do I go?"
end
end
t = TryIt.new
puts(t['blah'] = "It would be slightly surprising if I were returned, right?")
#=>
# testit.rb:3:in `[]=': look at the stack (RuntimeError)
# from testit.rb:9:in `<main>'
# update from sublime
# update from sublime 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment