Skip to content

Instantly share code, notes, and snippets.

@fronx
Last active December 28, 2015 23:39
Show Gist options
  • Save fronx/7580175 to your computer and use it in GitHub Desktop.
Save fronx/7580175 to your computer and use it in GitHub Desktop.

Scope of Names

For each of the following programs: what is the return value of the last expression? Why?

def a(a)
  a
end

a(1)
a = [1,2,3]
a.map { |x| a }
a = 1

def x
  a = 2
end

x
a  
a = [1,2,3]
a.map { |a| a }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment