so it seems there is no way to pass argument lists?
def throwem
return *[1, 2, 3]
end
def catchem(*args)
return args.length
end
puts catchem throwem #--> 1
the astrisk(*) amounts to nothing. 
···
–
tom sawyer, aka transami
transami@transami.net
Tom Sawyer wrote:
puts catchem throwem #–> 1
puts catchem *throwem #–> 3
the astrisk(*) amounts to nothing. 
Don’t tell it–it thinks it’s a star
Hi –
so it seems there is no way to pass argument lists?
def throwem
return *[1, 2, 3]
end
def catchem(*args)
return args.length
end
puts catchem throwem #–> 1
the astrisk(*) amounts to nothing. 
There’s nothing you can’t do, by way of passing arrays around; you
just have to process them according to what you’ve asked Ruby to do.
In this case, if you have:
def catchem(*args)
then you have to get at args[0] to see the first argument – which, in
this case, is itself an array. (It’s not that the * in throwem does
nothing; it’s that the way Ruby passes multiple return values is by
packaging them into an array.)
def throwem
return 1,2,3
end
def catchem(*args)
args[0].length
end
puts catchem(throwem) # 3
David
···
On Fri, 10 Jan 2003, Tom Sawyer wrote:
–
David Alan Black
home: dblack@candle.superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav
understood. thanks. unfortunately, i was trying to make my code a little
neater:
catchem throwthrew throwem
rather then having to do:
catchem *(throwthrew *throwem)
oh well, i’ll figure out another way.
···
On Thursday 09 January 2003 11:39 am, dblack@candle.superlink.net wrote:
There’s nothing you can’t do, by way of passing arrays around; you
just have to process them according to what you’ve asked Ruby to do.
In this case, if you have:
def catchem(*args)
then you have to get at args[0] to see the first argument – which, in
this case, is itself an array. (It’s not that the * in throwem does
nothing; it’s that the way Ruby passes multiple return values is by
packaging them into an array.)
def throwem
return 1,2,3
end
def catchem(*args)
args[0].length
end
puts catchem(throwem) # 3
–
tom sawyer, aka transami
transami@transami.net
.''.
.''. . *''* :_\/_: .
:_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
.‘’.: /\ : ./)\ ‘:’* /\ * : ‘…’. -=:o:=-
:/:‘.:::. | ’ ‘’ * ‘.'/.’ (/’.‘:’.’
: /\ : ::::: = / -= o =- /)\ ’ *
‘…’ ‘:::’ === * /\ * .‘/.'. ‘._____
* | … : |. |’ .—"|
* | _ .–’| || | _| |
* | .-‘| __ | | | || |
.-----. | |’ | || | | | | | || |
__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |.