Menu: Difference between revisions

18 bytes added ,  2 months ago
→‎{{header|D}}: Fix type mismatch
(→‎{{header|D}}: Fix type mismatch)
Line 783:
 
=={{header|D}}==
<syntaxhighlight lang="d">import std.stdio, std.conv, std.string, std.array, std.typecons;
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, "'.");
}
}</syntaxhighlight>
 
{{out}}
<pre>Choose one:
Choose one:
0) fee fie
1) huff and puff
Line 825 ⟶ 829:
3) tick tock
> 2
You chose 'mirror mirror'.</pre>
</pre>
 
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
117

edits