Last active
August 29, 2015 14:25
-
-
Save jimeh/9f3658c80643bc0eefca to your computer and use it in GitHub Desktop.
Weird Ruby variable assignment behavior
This file contains hidden or 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
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