function read(mixed $key): string {
return match ($key) {
1 => 'Integer 1',
'1' => 'String 1',
true => 'Bool true',
[] => 'Empty array',
[1] => 'Array [1]',
};
}
read(1); // "Integer 1"
read('1'); // "String 1"
read(true); // "Bool true"
switch 랑 다르게 타입체크도 하면서 매칭해줌
switch 랑 다르게 타입체크도 하면서 매칭해줌
러스트에 있던건데 파이썬이랑 php에도 들어옴