Skip to content

Instantly share code, notes, and snippets.

@guiman
Created July 2, 2015 11:47
Show Gist options
  • Save guiman/d83baaa0bdff58e97d82 to your computer and use it in GitHub Desktop.
Save guiman/d83baaa0bdff58e97d82 to your computer and use it in GitHub Desktop.
Ruby 2.1.4 defines variables on unexecuted if block conditions
$ irb
irb(main):001:0> that
NameError: undefined local variable or method `that' for main:Object
from (irb):1
from /Users/guiman/.rbenv/versions/2.1.4/bin/irb:11:in `<main>'
irb(main):002:0> (true) ? this = "a" : that = "b"
=> "a"
irb(main):003:0> that
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment