From: "Ondřej Bílka" Date: 2012-03-17T21:07:06+09:00 Subject: [ruby-core:43367] Arguments, assignment and pattern matching. Hello, I wonder what should be ideal way to pass arguments and do mass assignment. First a question: What should following code do in ruby2.0? def foo(x,*y,z) puts [x,y,z] end foo(1,2,y:[1,2]) I assume that arguments can be captured in Argument object. This gives us also multiple return for free. def foo(*a);a;end foo(1,2,x:1,y:2) # Argument[1,2]{x:1,y:2} [3,4,a:1,b:2] # Argument[3,4]{a:1,b:2} Argument object extends array and you can access named arguments via arguments method. I plan extend ruby with pattern matching in my amethyst project. My current vision is following: [a,[b,c]]= [1,[2,3]] amethyst Amethyst { tree = Tree #Class pattern matches objects of given class | Leaf -> Tree[nil,nil] } def foo( _:(Int:x | Float:y) , _:tree[ l:@left,r:@right ]) return [4,l,a:x,b:y] end [ z,l, a:@a, b:@b ]= foo(1,Tree[1,2]) [ z,l, a:@a, b:@b ]= foo(1,Leaf[]) This could be way how add more flexible splat when I am done. How it is similar to current plan of keyword arguments? -- Fluorescent lights are generating negative ions. If turning them off doesn't work, take them out and put tin foil on the ends.