From: jcb@... (MetalOne) Date: 2003-01-12T05:44:04+09:00 Subject: parameters and their assignment to the argument list: logical/consistent? I was wondering if anybody thinks there is anything illogical or inconsistent with the following two pieces of code. code sample 1: splitting a list into it's head and tail. h, *t = [1,2,3] h ==> 1 t ==> [2,3] ----------------------- code sample 2: passing a list to a function accepting two arguments. def f(h, *t) # actual result # h ==> [1,2,3] # t ==> [] # my expected result # h ==> 1 # t ==> [2,3] end f [1,2,3] --------------- I was expecting the assignment of parameters to arguments to work the same way as normal assignment. The downside to the way it works now is demonstrated by the following quick sort code: def qs(arr) return [] if arr.length <= 0 x, *xs = arr qs(xs.select{ |y| y <= x } ) + [x] + qs(xs.select{ |y| y > x } ) end However, it could have been written more concisely as #pseudo code def qs(x, *xs) return [] if x.nil? qs(xs.select{ |y| y <= x } ) + [x] + qs(xs.select{ |y| y > x } ) end