Skip to content

Commit 6387537

Browse files
Add match section
1 parent b5cac84 commit 6387537

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

spec.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ if (
710710
}
711711
```
712712

713-
### 5.2 `switch`, `case`
713+
### 5.2 `switch`, `case`, `match`
714714

715715
A `switch` structure looks like the following. Note the placement of
716716
parentheses, spaces, and braces. The `case` statement MUST be indented once
@@ -757,6 +757,19 @@ switch (
757757
}
758758
```
759759

760+
Similarly, a `match` expression looks like the following. Note the placement
761+
of parentheses, spaces, and braces.
762+
763+
```php
764+
<?php
765+
766+
$returnValue = match ($expr) {
767+
0 => 'First case',
768+
1, 2, 3 => multipleCases(),
769+
default => 'Default case',
770+
};
771+
```
772+
760773
### 5.3 `while`, `do while`
761774

762775
A `while` statement looks like the following. Note the placement of

0 commit comments

Comments
 (0)