Suliman:

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

?

"is" performs a raw comparison of just the values, and the value of a string is its ptr and length field. While "==" compares their contents. So you want to use "==" here because you are interested to see if x contains the char 'q', because while their lengths could be equal, their ptr is surely different.

Bye,
bearophile

Reply via email to