Skip to content

Instantly share code, notes, and snippets.

@JuzerShakir
Last active June 30, 2021 04:44
Show Gist options
  • Save JuzerShakir/bb68f76977a68515c946ea1584343ed5 to your computer and use it in GitHub Desktop.
Save JuzerShakir/bb68f76977a68515c946ea1584343ed5 to your computer and use it in GitHub Desktop.
Local Variable medium
local_var = "I am local var defined in root."
puts local_var # => "I am local var defined in root."
# accessing local var which is defined in root
def access
puts local_var # => NameError
end
# accessing variable in nested method
def parent_method
local_var = "I am local var defined in a method."
def child_method
puts local_var # => NameError
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment