Created
July 14, 2010 18:35
-
-
Save avescodes/475813 to your computer and use it in GitHub Desktop.
Apparently even if a local variable declaration isn't run it will still shadow a method with the same name
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
def thing | |
"ASDF" | |
end | |
puts thing #=> ASDF | |
if false | |
thing = "JKL:" | |
end | |
puts thing #=> nil | |
puts thing() #=> "ASDF" | |
# Edit: The work around (for the context I was working in) | |
thing = thing || thing() # self.thing would work too |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Neat, thanks for sharing. Never knew or have come across that :)