I was trying to figure out how to do the equivalent of (in Perl):
$one, $two, @rest = @ARGV
and it seems that I can do:
one, two, *rest = ARGV
in Ruby. However, I can’t see this documented anywhere (I looked in
the pickaxe, and in the manual shipped with Debian’s ruby-manual
package), and I wanted to make sure I could rely on it working in
future versions of Ruby.
I do see it used in method parameters:
def method(one,two,*rest)
#…
end
But nobody seems to say that you can do it generically in assignments,
and I’m always a tad nervous about using what appear to be
undocumented language features.
If this is documented, of course, a pointer to where would be nice.
Note: Source code doesn’t count.
-=Eric
···
–
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton
I was trying to figure out how to do the equivalent of (in Perl):
$one, $two, @rest = @ARGV
and it seems that I can do:
one, two, *rest = ARGV
in Ruby. However, I can’t see this documented anywhere (I looked in
the pickaxe, and in the manual shipped with Debian’s ruby-manual
package), and I wanted to make sure I could rely on it working in
future versions of Ruby.
I do see it used in method parameters:
def method(one,two,*rest)
#…
end
But nobody seems to say that you can do it generically in assignments,
and I’m always a tad nervous about using what appear to be
undocumented language features.
If this is documented, of course, a pointer to where would be nice.
Note: Source code doesn’t count.
-=Eric
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton