Skip to content

Instantly share code, notes, and snippets.

@wapcaplet
Created December 2, 2011 22:27
Show Gist options
  • Save wapcaplet/1425136 to your computer and use it in GitHub Desktop.
Save wapcaplet/1425136 to your computer and use it in GitHub Desktop.
def foo(var, hash1={}, hash2={})
puts "var: #{var.inspect}"
puts "hash1: #{hash1.inspect}"
puts "hash2: #{hash2.inspect}"
end
> foo('x', 'y', 'z')
var: "x"
hash1: "y"
hash2: "z"
> foo('x', {'y'=>1, 'z'=>2})
var: "x"
hash1: {"y"=>1, "z"=>2}
hash2: {}
> foo('x', 'y'=>1, 'z'=>2)
var: "x"
hash1: {"y"=>1, "z"=>2}
hash2: {}
> foo('x', {'y'=>1}, {'z'=>2})
var: "x"
hash1: {"y"=>1}
hash2: {"z"=>2}
> foo({'y'=>1}, {'z'=>2})
var: {"y"=>1}
hash1: {"z"=>2}
hash2: {}
> foo('y'=>1, 'z'=>2)
var: {"y"=>1, "z"=>2}
hash1: {}
hash2: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment