Skip to content

Instantly share code, notes, and snippets.

/kwargs.rb Secret

Created February 19, 2016 17:04
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 anonymous/a5dae683e0c0a27cd4e2 to your computer and use it in GitHub Desktop.
Save anonymous/a5dae683e0c0a27cd4e2 to your computer and use it in GitHub Desktop.
handling keyword args
jupiter:~/JAVA/swf-converter-conversion-node$ time perl6 -e '
sub foo(*@args, *%kwargs) {
print %kwargs
}
foo(1,2,3,a=> 1, b => 2)
'
a 1b 2
real 0m0.613s
user 0m0.446s
sys 0m0.145s
gregf@jupiter:~/JAVA/swf-converter-conversion-node$
jupiter:~/JAVA/swf-converter-conversion-node$ time ruby -le '
def foo(*args, **kwargs)
p kwargs
end
foo(1,2,3,{a:1, b: 2})
'
{:a=>1, :b=>2}
real 0m0.038s
user 0m0.034s
sys 0m0.004s
jupiter:~/JAVA/swf-converter-conversion-node$ time python -c '
def foo( *args, **kwargs):
print kwargs
foo(1,2,3, a=1, b=2)
'
{'a': 1, 'b': 2}
real 0m0.013s
user 0m0.005s
sys 0m0.008s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment