Little problem with the "+" operator
Fredrik Aronsson
d98aron at dtek.chalmers.se
Mon Mar 5 15:36:12 EST 2001
In article <mt1yscm7yu.fsf at astron.berkeley.edu>,
Johann Hibschman <johann at physics.berkeley.edu> writes:
> Joshua Marshall writes:
>
>>> This is infinitely more sane than:
>
>>> % perl -e 'print 500 + "cool"'
>>> 500
>
>> Comparing Python to Perl here doesn't seem very fair. They're very
>> different languages. In general, I'm surprised by the urgency with
>> which people often jump to compare them.
>
> Well, Perl's the only language that I know of that lets you add 500 to
> "cool" without an error. Well, I suppose tcl might. But it's still a
> fairly safe inference that the original poster was coming from Perl.
>
Well, my first guess was Java.
public class Test {
public static void main(String[] args) {
int variableOne = 500;
String myVariable = variableOne + "cool";
System.out.println(myVariable);
}
}
gere(1)> javac Test.java
gere(2)> java Test
500cool
Since I havn't found a % operator or a printf function, I like it.
/Fredrik
(Well, I have gotten to like Haskell a lot more after learning Java,
wrote a complete parser+typechecker for a little language,
211 lines in Haskell
~2400 lines in Java (and I'm not counting the generated code.))
More information about the Python-list
mailing list