On Tue, 04 Feb 2014 03:08:28 -0500, Suliman <everm...@live.ru> wrote:

What difference between
if ((x = stdin.readln().chomp) is "q")
and
if ((x = stdin.readln().chomp) == "q")

?

The first compares the pointer of the arrays. The second compares the contents of the array. Both check length as well for equality.

In other words, the first will always be false (the ROM literal "q" will never have the same address as some heap block), the second will be true if the input was the string "q".

More generally, 'is' should be a bitwise comparison of the variables. '==' should check for logical equality, whatever that means for the variable types.

-Steve

Reply via email to