Skip to content

Instantly share code, notes, and snippets.

@nickyp
Created March 19, 2012 13:41
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 nickyp/2112612 to your computer and use it in GitHub Desktop.
Save nickyp/2112612 to your computer and use it in GitHub Desktop.
default parameter references another parameter
foo = {:foo => "bar", :olaf => "polaf"}
bar = 2
def olaf(one, two = one[:foo])
puts "#{one} - #{two}\n"
end
olaf(foo)
olaf(foo, bar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment