[Issue 596] Support array, arrayliteral and struct in switch and case
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 3 04:24:45 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=596
--- Comment #10 from bearophile_hugs at eml.cc 2013-03-03 04:24:29 PST ---
When final switch supports structs, writing a fizzBuzz
(http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/
) gets simpler and safer:
import std.stdio, std.typecons;
void main() {
foreach (immutable i; 1 .. 101) {
final switch (tuple(i % 3 == 0, i % 5 == 0)) {
case tuple(false, false): writeln(num); break;
case tuple(false, true): writeln("Buzz"); break;
case tuple( true, false): writeln("Fizz"); break;
case tuple( true, true): writeln("FizzBuzz"); break;
}
}
}
--
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