Created
May 14, 2010 04:22
-
-
Save itabatakafumi/400808 to your computer and use it in GitHub Desktop.
可変長引数と名前付き引数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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