Of course, you can also do without “default” or specify several values separated by commas:
Before:
switch ($variable) {
case 'foo':
$newVariable = anyFunctionFoo();
case 'bar':
$newVariable = anyFunctionBar();
default:
$newVariable = 'foobar';
} After:
$newVariable = match ($variable) {
'foo' => anyFunctionFoo(),
'bar' => anyFunctionBar(),
default => 'foobar',
}; Of course, you can also do without “default” or specify several values separated by commas:
$newVariable = match ($variable) {
'foo', 'foobar' => anyFunctionFoo(),
'bar' => anyFunctionBar(),
};




