----- Original Message -----
From: "Jason Williams" <jason / jasonandali.org.uk>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Wednesday, August 20, 2003 12:09 PM
Subject: Re: ParseDate and Time


> In article <20030820142735.GA22454 / mulan.thereeds.org>, Mark J. Reed
wrote:
> > irb(main):009:0> puts Time.gm(*parsedate("1993-01-01T00:00:00Z"))
> > Fri Jan 01 00:00:00 UTC 1993
> > => nil
>
> Ah, it seems to be that * I was missing; what does that do? (Sorry, I'm
> new to Ruby :-)

The star is array expansion.

E.g., this

  arr = [x,y,z]
  foo(*arr)

is essentially the same as

  foo(x,y,z)

and note that

  foo(arr)

passes in a *single* arg which happens to be an array.

Star in a method definition similarly indicates a
variable number of parameters, treated as an array:

  def foo(*args)
    p args
  end

  foo(1,2,3)     # Prints [1,2,3]
  foo(4)         # Prints [4]
  foo            # prints []

Hope this helps...
Hal