This is the problem with writing "clever" code...it's unreadable!

The * operator used here is a unary operator that is used to convert
an array into a list of arguments.  For example, say you had this
method:

def say(a, b, c)
  puts a
  puts b
  puts c
end

If you had this array:

arr = [1, 2, 3]

As a convenience, Ruby lets you pass each element of the array as a
separate argument into the method by using the * operator:

say(*arr)

In the case of p *1..100, the trick seems to work for a range, too.

On Jan 30, 4:36 pm, Dominik Honnef <domini... / gmx.net> wrote:
> On [Thu, 31.01.2008 06:24], Lee Jarvis wrote:
>
> > On Jan 30, 9:14 pm, Wyatt Greene <green... / yahoo.com> wrote:
> > > Write a Ruby program that prints out the numbers 1 to 100, one number
> > > per line.  The program must be less than 10 characters long.
>
> > > Good luck!
> > > Wyatt Greene
>
> > Lol whats this all about?
>
> > Well, just for the crack..
>
> > p *1..100
>
> Would you be so gentle and explain this piece of code to me?
> I know things like p "a"*10, but I dont really understand your code.
> I know that 1..100 describes a range, but... isn't * a binary operator? I don't really see the first/second operand
>
> --
> Dominik Honnef