From: Joe Van Dyk Date: 2005-08-27T04:05:24+09:00 Subject: Re: ruby quiz question '*' on the initialize parameters On 8/26/05, Gaston Garcia wrote: > well, now I got lost with that reverse example. but I did get the first one. > > thanks! : ) % cat a.rb def foo x, y, z puts "x: #{ x }, y: #{ y }, z: #{ z }" end my_array = [1, 2, 3] foo *my_array % ruby a.rb x: 1, y: 2, z: 3 > On 8/26/05, James Edward Gray II wrote: > > > > On Aug 26, 2005, at 1:24 PM, Gaston Garcia wrote: > > > > > Thanks james, that's a beautiful thing that does!!! > > > > It also works in reverse. Watch this: > > > > irb(main):001:0> def var_args( *args ) > > irb(main):002:1> fixed_args(*args) # expanded back out > > irb(main):003:1> end > > => nil > > irb(main):004:0> def fixed_args( one, two, three ) > > irb(main):005:1> p three > > irb(main):006:1> end > > => nil > > irb(main):007:0> var_args 1, 2, 3 > > 3 > > => nil > > > > James Edward Gray II > > > > > > > > > -- > -gaston > >