3 ms·
> Most people treat switch as a peculiar form of match (or cond or whatever) Completely made up switch illustrates how I use it in every language if I can...Go
by Supermancho 7y ago
> Most people treat switch as a peculiar form of match (or cond or whatever)
Completely made up switch illustrates how I use it in every language if I can...Go has a succinct version of this.
switch(True) {
case ($x == 1):
$x++;
break;
case ($x > 3):
$x--;
break;
default:
break;
}
- edflsafoiewq 7y agoWhy? It's longer, more complex, and more highly indented than a normal if-elif-else.