Skip to content

Instantly share code, notes, and snippets.

@jimeh
Last active August 29, 2015 14:25
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 jimeh/9f3658c80643bc0eefca to your computer and use it in GitHub Desktop.
Save jimeh/9f3658c80643bc0eefca to your computer and use it in GitHub Desktop.
Weird Ruby variable assignment behavior
puts defined?(hello).inspect # => nil
puts "this will not print #{hello.inspect}" rescue nil
hello = 'dude' if false
puts defined?(hello).inspect # => "local-variable"
puts hello.inspect # => nil
# Outputs:
#
# nil
# "local-variable"
# nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment