3 ms·
Kind of depends on the language. Perl converts the string to an integer if you use a math operator on a numeric string. Python just throws an error.
by weare138 6y ago
Kind of depends on the language. Perl converts the string to an integer if you use a math operator on a numeric string. Python just throws an error.
- erik_seaberg 6y agoWhen I want either addition or string concatenation, I know it, I can't think of a use case where I'm happy getting either randomly. Perl got this right: 2 + 2 == 4 2 . 2 eq 22 You can even declare that failed conversions should throw: use warnings FATAL => qw(numeric)
- sergeykish 6y agoYes, perl is consistent perl print "2" + 1 3 print "2" - 1 1 js > "2" + 1 "21" > "2" - 1 1
- weare138 6y agoAnother thing I thought was clever about Perl is it has two comparison operators, '==' for numeric values and 'eq' for strings.