Skip to content

Instantly share code, notes, and snippets.

@itabatakafumi
Created May 14, 2010 04:22
Show Gist options
  • Save itabatakafumi/400808 to your computer and use it in GitHub Desktop.
Save itabatakafumi/400808 to your computer and use it in GitHub Desktop.
可変長引数と名前付き引数
def obj.foo(*args)
h = {:name=>"A", :no=>1}
last = args.pop
if last.is_a?(Hash)
last.each do|key,value|
h[key] = value
end
else
args << last
end
"#{args.inspect} #{h.inspect}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment