On Monday, 27 July 2015 at 16:48:00 UTC, Alex wrote:
Okay. By pure trying I found out what I did wrong:

Apparently by typing Y I entered the shift key. Could that have been the problem? I changed it to a small y and it at least jumped back to the commandline instead of just being stuck.

And by changing:

writeln("Do you want to play again? Y/N?");
        readln(yesno);
        if (yesno == "y") {
                writeln("Yeah!");
        }

to:

writeln("Do you want to play again? Y/N?");
        readln(yesno);
        if (yesno != "y") {
                writeln("Yeah!");
        }

So instead of ==   I used  !=

Now it works. But I still do not know why..

readln includes the '\n' at the end, so when you typed "Y" and pressed enter, readln returned "Y\n" which != "Y".

Reply via email to