Skip to content

Instantly share code, notes, and snippets.

@choallin
Last active October 8, 2019 20:21
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 choallin/800ed8a7d966b260b020e0e3c54eaab2 to your computer and use it in GitHub Desktop.
Save choallin/800ed8a7d966b260b020e0e3c54eaab2 to your computer and use it in GitHub Desktop.
dynamical_scoping
def multiply_by_two
  multiplicand = 2
  test_method
end
def multiply_by_three
 multiplicand = 3
  test_method
end
def test_method
  different_variable = [1,2,3]
  different_variable.map do |number|
  number * multiplicand
  end
end
puts multiply_by_two # => [2,4,6]
puts multiply_by_three # => [3,6,9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment