N
ngoc
Hi
In perl
print $_, "\n" foreach (@array);
In Ruby
array.each { |e| print e, "\n" }
or
array.each do |e| print e, "\n" end
So |e| is similar to $_. But I can not
say
{ |e| print e, "\n"} array.each
because of block as argument and OO issue. In addition, it looks a
little bit complicated in Ruby. I think in THIS CASE perl is more
elegant than Ruby?
Is it a right thinking (IN THIS CASE)?
Are there other ways than those two array.each?
(I am not very knowledgeable guy).
Thanks
ngoc
In perl
print $_, "\n" foreach (@array);
In Ruby
array.each { |e| print e, "\n" }
or
array.each do |e| print e, "\n" end
So |e| is similar to $_. But I can not
say
{ |e| print e, "\n"} array.each
because of block as argument and OO issue. In addition, it looks a
little bit complicated in Ruby. I think in THIS CASE perl is more
elegant than Ruby?
Is it a right thinking (IN THIS CASE)?
Are there other ways than those two array.each?
(I am not very knowledgeable guy).
Thanks
ngoc