From: gabriele renzi Date: 2004-05-26T07:18:45+09:00 Subject: Re: ruby-dev summary 23459-23562 il Tue, 25 May 2004 23:00:03 +0900, Minero Aoki ha scritto:: > [Keyword Arguments] > > * Syntax > > def m(a, b=nil, *rest, c:val, **krest) > p a #=> 1 > p b #=> 2 > p rest #=> [3, 4, 44, 444] > p c #=> 55 > p krest #=> {:d => 66, :e => 77, :f => 88} > end > > array = [4, 44, 444] > hash = {e: 77, f: 88} > m(1, 2, 3, *array, c:55, d:66, **hash) Why do we need to make a distinction beetween named arguments and positional ones? Given that they will be considered Values can't we make Value both an array and an hash? I'm stupid and I really need to sleep, but why can't we handle this just from the calling side? say: def m(a,b=nil,c=val,*rest,**krest) p a # 1 p b # 2 p c # 55 p rest # [3, 4, 44, 444] p krest # {:d => 66, :e => 77, :f => 88} end m(1, 2, c:55, d:66,3,*array, **hash) This way we could take advantage of all the existing code, and write stuff like: def f(a=10,b=20,c=30) return a,b,c end p f() # [10,20,30] p f(*[1,2,3]) # [1,2,3] p f(a:10,c:40) # [10,20,40]