- or download this
use strict;
use warnings;
my $x = "2abc";
my $y = $x + 42;
print "x=", $x, " y=", $y, "\n";
- or download this
Argument "2abc" isn't numeric in addition (+) at f.pl line 4.
x=2abc y=44
- or download this
x = "2abc"
y = x + 42
print "x=", x, "y=", y, "\n"
- or download this
Traceback (most recent call last):
File "f.py", line 2, in <module>
y = x + 42
TypeError: cannot concatenate 'str' and 'int' objects
- or download this
x = "2abc"
y = int(x) + 42
print "x=", x, "y=", y, "\n"
- or download this
Traceback (most recent call last):
File "f2.py", line 2, in <module>
y = int(x) + 42
ValueError: invalid literal for int() with base 10: '2abc'
- or download this
x = "2abc"
y = int(x[0:1]) + 42
print "x=", x, "y=", y, "\n"
- or download this
x= 2abc y= 44
- or download this
x = "2abc"
y = x + 42
print "x=", x, "y=", y, "\n"
- or download this
f.rb:2:in `+': can't convert Fixnum into String (TypeError)
from f.rb:2
- or download this
x = "2abc"
y = x.to_i() + 42
print "x=", x, " y=", y, "\n"
- or download this
x=2abc y=44