How to complex switch?

Matthew Ong ongbp at yahoo.com
Thu May 12 04:13:59 PDT 2011


Hi All,

Anyway to include this cool feature of switch with D in the near future?

switch(str){
                   // regexp
case "abc", "def", "as+b?": s1(); break;

case "za+", "wd?", "aaa": s2(); break;

default: s3();
}

switch (tag) {
default: s3()
case 0, 1, 2, 3: s1()
case 4, 5, 6, 7: s2()
}

switch (x := f();) {  // missing switch expression means "true"
case x < 0: return -x
default: return x
}

switch (x){
case x < y: f1()
case x < z: f2()
case x == 4: f3()
case z+y: f4()
}


More information about the Digitalmars-d mailing list