From: markus jais Date: 2001-07-27T01:12:33+09:00 Subject: [ruby-talk:18573] ruby versus Perl Magic hi, I have a small problem the following Perl Script called "my.pl" works when called like this: $ ./my.pl 4 -------------------- #!/usr/bin/perl -w $i = 1; $ a = $ARGV[0] + $i; print "$a\n"; ------------------- the output is of course 5 but the following ruby script "my.rb" does not work when called: $ ./my.rb 4 -------------------- #!/usr/local/bin/ruby -w i = 1 a = i + ARGV[0] print a, "\n" ------------------ the error I get: ./my.rb:4:in `+': String can't be coerced into Fixnum (TypeError) from ./my.rb:4 Obviously the Perl Magic does not work in Ruby. I have to write ARGV[0].to_i Does Ruby also support "Magic" as some Perl folks call this that is, to convert variables automatically when used in a mathematical expression. if yes, how can I tell Ruby to be magic I think that this is not possible in Ruby, and Matz had good reasons for this. Because I am neither a Perl nor a Ruby guru (yet), I would like to hear the reason for this. regards markus -- Markus Jais http://www.mjais.de info@mjais.de The road goes ever on and on - Bilbo Baggins ------------------------------------------------------- -- Markus Jais http://www.mjais.de info@mjais.de The road goes ever on and on - Bilbo Baggins