Skip to content

Commit 89fbefa

Browse files
authored
Merge pull request #21 from JesusValera/match
Add match section
2 parents cadf3a2 + 6387537 commit 89fbefa

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
@@ -791,7 +791,7 @@ if (
791791
}
792792
```
793793

794-
### 5.2 `switch`, `case`
794+
### 5.2 `switch`, `case`, `match`
795795

796796
A `switch` structure looks like the following. Note the placement of
797797
parentheses, spaces, and braces. The `case` statement MUST be indented once
@@ -838,6 +838,19 @@ switch (
838838
}
839839
```
840840

841+
Similarly, a `match` expression looks like the following. Note the placement
842+
of parentheses, spaces, and braces.
843+
844+
```php
845+
<?php
846+
847+
$returnValue = match ($expr) {
848+
0 => 'First case',
849+
1, 2, 3 => multipleCases(),
850+
default => 'Default case',
851+
};
852+
```
853+
841854
### 5.3 `while`, `do while`
842855

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

0 commit comments

Comments
 (0)