David A. Black wrote: >>> def m(a,b="b",c="c",d); p [a,b,c,d]; end > => nil >>> m(1,2,3) > [1, 2, "c", 3] > => [1, 2, "c", 3] > > I would expect [1, 3, "c", 2], because I would expect d (a required > argument) to be handled before b (an optional argument). > > I know it's almost unthinkable that one would use this method > signature, but I'd still like to understand the reasoning fully. I > thought the idea was: handle the required arguments first, but it > seems to be: move from left to right, looking ahead at every point to > see whether there are enough arguments left and, at that point, give > the right-hand required arguments priority. Is that right? class C def []=(a, b=:x, *c, d) p [[a, b, c], d] end end c = C.new c[1] = 2 c[1, 2] = 3 c[1, 2, 3] = 4 c[1, 2, 3, 4] = 5 #=> [[1, :x, []], 2] [[1, 2, []], 3] [[1, 2, [3]], 4] [[1, 2, [3, 4]], 5] main purpose of post argument is to get rhs (right hand side) value at arrey assignedment like method. On an above example, variable "d" is rhs value. -- // SASADA Koichi at atdot dot net