Created
June 1, 2016 11:08
-
-
Save suhlig/022ab73ad2d7c09cee8e5e235a00ff48 to your computer and use it in GitHub Desktop.
Side effect of defined?
This file contains 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
$ pry | |
pry> foo | |
NameError: undefined local variable or method `foo' for main:Object | |
pry> if defined?(foo) | |
* bar = 1 | |
* end | |
=> nil | |
pry> if defined?(bar) | |
* puts "oops" | |
* end | |
oops |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@avdi answered this in RubyTapas' Episode #412: Autovivification: