Created
June 1, 2014 23:34
-
-
Save doug7410/e2ea22f32155085a325c to your computer and use it in GitHub Desktop.
Does a method create it's own scope?
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
#If you define a method does it create a scope within itself? Don't any variables or methods used within a method need to be passed in as arguments? | |
#Here's an example | |
name = "Frank" | |
def say_hello(n) | |
def hello_method | |
"hello" | |
end | |
puts hello_method + " #{n}" | |
end | |
def hello_again(n) | |
puts hello_method + " #{n}" | |
end | |
say_hello(name) | |
hello_again(name) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment