Skip to content

Instantly share code, notes, and snippets.

@nel
Created September 28, 2011 13:49
Show Gist options
  • Save nel/1247975 to your computer and use it in GitHub Desktop.
Save nel/1247975 to your computer and use it in GitHub Desktop.
foo # NameError: undefined local variable or method `foo' for main:Object
foo = "bar" unless defined?(foo)
foo # => nil
@nel
Copy link
Author

nel commented Nov 6, 2011

Yep, it's ok in the case you want scope wide memoization on that variable. But you are right we are diverging the purpose of the gist/comments was just to expose corner case in ruby language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment