Menu: Difference between revisions

5 bytes added ,  2 months ago
(→‎{{header|D}}: Fix type mismatch)
Line 792:
try {
immutable n = input.to!int;
 
return typeof(return)((n >= 0 && n <= nEntries) ? n : -1);
} catch (Exception e) // Very generic
Line 805 ⟶ 806:
writefln(" %d) %s", i, entry);
"> ".write;
 
immutable input = readln.chomp;
 
immutable choice = validChoice(input, cast(int) (entries.length - 1));
 
if (choice.isNull)
"Wrong choice.".writeln;
Line 817 ⟶ 821:
immutable items = ["fee fie", "huff and puff",
"mirror mirror", "tick tock"];
 
writeln("You chose '", items.menuSelect, "'.");
}
117

edits