< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous (in thread)
N :the next (in thread)
|<:the top of this thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
On Fri, Aug 08, 2003 at 01:46:20AM +0900, Rudolf Polzer wrote:
> he means, that in Perl you can do:
>
> use Data::Dumper;
> @l = qw(one two three);
> for my $elem(@l)
> {
> $elem = 'X' . uc $elem;
> }
> print Dumper \@l;
>
> which yields
>
> $VAR1 = [
> 'XONE',
> 'XTWO',
> 'XTHREE'
> ];
In Ruby:
l = %w{one two three}
l.each do |elem|
elem.replace('X' + elem.upcase)
end
p l
In other words, you have to mutate the existing element; assigning to 'elem'
does not replace the element, it simply makes the local variable point
elsewhere.
There is some Bad Magic going on in the Perl version; somehow $elem is
aliasing an element of the array, it is not a normal variable at all.
> Of course, elem.upcase!() would solve the problem... but in this case,
> eventually the equivalent of Perl's map operator, Array#collect and
> Array#collect!, are more appropiate:
>
> l = %w{one two three}
> l.collect!() do |elem|
> 'X' + elem.upcase()
> end
> p l
Except the question was about hashes, and hashes don't have collect! (which
is really an Array method)
Regards,
Brian.