Skip to content

Instantly share code, notes, and snippets.

@rafaelss
Created July 25, 2012 13:09
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 rafaelss/3176106 to your computer and use it in GitHub Desktop.
Save rafaelss/3176106 to your computer and use it in GitHub Desktop.
class A
def foo
case true
when true
puts defined?(bar)
puts "nil? #{bar}"
when false
bar = "something else"
raise "here? no"
end
puts defined?(bar)
puts "nil? #{bar.inspect}"
end
def bar
@bar ||= "baz"
end
end
A.new.foo
$ ruby tmp/a.rb
method
nil? baz
local-variable
nil? nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment