[Issue 11213] New: Simplify switch case-range statement
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 9 16:19:05 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11213
Summary: Simplify switch case-range statement
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-10-09 16:19:04 PDT ---
The current case-range syntax is rather awkward and verbose:
-----
import std.stdio;
void main()
{
foreach (x; 0 .. 10)
{
switch (x)
{
case 0: .. case 4:
writeln("a");
break;
case 5: .. case 9:
writeln("b");
break;
default:
}
}
}
-----
I suggest we allow the syntax "case 0 .. 4:", e.g.:
-----
switch (x)
{
case 0 .. 4:
writeln("a");
break;
case 5 .. 9:
writeln("b");
break;
default:
}
-----
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list