From: Ross Bamford Date: 2005-12-02T00:27:31+09:00 Subject: Re: require! On Thu, 01 Dec 2005 15:01:05 -0000, Brian Buckley wrote: >> Actually * looks for a to_a. > > Does calling amethod(*x) have the same meaning as calling > amethod(x.to_a)? If is it what is the benefit of using the (less > clear) first way? > > Brian Buckley > > It 'unwraps' a supplied [anything] to multiple declared arguments. Imagine: def amethod(one,two,three) puts one, two, three end If you call that with: amethod((1..3).to_a) you'll get an error, because you only supplied one argument - the array. If you specify the '*', however: amethod(*(1..3)) The range first gets converted to an array with to_a, and then that is expanded into the method's argument list. You can double-check by specifying either 1..2 or 1..4, which gives an ArgumentError. -- Ross Bamford - rosco@roscopeco.remove.co.uk "\e[1;31mL"