Yes or No Options
    Namespace via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Mon Jul 27 09:10:58 PDT 2015
    
    
  
Look at my example:
----
import std.stdio;
import std.string;
import std.conv : to;
void main()
{
     while (true) {
         write("Roll the dice: Enter a number: ");
         int dieNumber = readln.strip.to!int;
         if (dieNumber < 4) {
             writeln("You won!");
         }
         else if ((dieNumber >= 4) && (dieNumber <= 6)) {
             writeln("I won!");
         }
         else if (dieNumber > 6){
             writeln("ERROR: Invalid Value");
         }
         writeln("Do you want to play again? Y/N?");
         immutable string yesno = readln.strip;
         if (yesno.toLower() != "y")
             break;
         writeln("Let's go again!");
     }
}
----
With the while loop you really can "go again" ;)
    
    
More information about the Digitalmars-d-learn
mailing list