Re: [vox-tech] ruby (was: hold on to your hats - perl vs python)

2002-07-18 Thread Rod Roark

On Thursday 18 July 2002 04:30 pm, Henry House wrote:
 ...
 I like writing

   'a b c d'.split(/\s/).each do |i|
   puts elem = #{i}
   end

 than

   foreach my $i (split(/\s/, a b c d)) {
   print elem = $i\n
   }

Actually the Perl version can be a bit more succinct:

  for (split /\s/, a b c d) {print elem = $_\n}

BTW does ruby let you do one-liners as in perl -e?

-- Rod
   http://www.sunsetsystems.com/

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] ruby (was: hold on to your hats - perl vs python)

2002-07-18 Thread Henry House

On Thu, Jul 18, 2002 at 04:49:13PM -0700, Rod Roark wrote:
 On Thursday 18 July 2002 04:30 pm, Henry House wrote:
  ...
  I like writing
 
  'a b c d'.split(/\s/).each do |i|
  puts elem = #{i}
  end
 
  than
 
  foreach my $i (split(/\s/, a b c d)) {
  print elem = $i\n
  }
 
 Actually the Perl version can be a bit more succinct:
 
   for (split /\s/, a b c d) {print elem = $_\n}

True. I consider $_ and friends to be ugliness best avoided, however. Perl
can be made plenty succinct, but usually at the cost of readability. To read
such perl code you need to keep a lot of syntax rules in your head.

Btw, the best place to learn about ruby is www.ruby-lang.org.

-- 
Henry House
The attached file is a digital signature. See http://romana.hajhouse.org/pgp
for information.  My OpenPGP key: http://romana.hajhouse.org/hajhouse.asc.



msg03189/pgp0.pgp
Description: PGP signature