Menu: Difference between revisions
→{{header|D}}: Fix type mismatch
Langurmonkey (talk | contribs) |
(→{{header|D}}: Fix type mismatch) |
||
Line 783:
=={{header|D}}==
<syntaxhighlight lang="d">
import std.stdio, std.conv, std.string, std.array, std.typecons;
string menuSelect(in string[] entries) {
Line 805 ⟶ 806:
"> ".write;
immutable input = readln.chomp;
immutable choice = validChoice(input, cast(int) (entries.length - 1));
if (choice.isNull)
"Wrong choice.".writeln;
Line 817 ⟶ 818:
"mirror mirror", "tick tock"];
writeln("You chose '", items.menuSelect, "'.");
}
{{out}}
<pre>
Choose one:
0) fee fie
1) huff and puff
Line 825 ⟶ 829:
3) tick tock
> 2
You chose 'mirror mirror'.
</pre>
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
|