Skip to content

Commit

Permalink
Merge pull request #21 from JesusValera/match
Browse files Browse the repository at this point in the history
Add match section
  • Loading branch information
KorvinSzanto authored Aug 9, 2022
2 parents cadf3a2 + 6387537 commit 89fbefa
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ if (
}
```

### 5.2 `switch`, `case`
### 5.2 `switch`, `case`, `match`

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

Similarly, a `match` expression looks like the following. Note the placement
of parentheses, spaces, and braces.

```php
<?php

$returnValue = match ($expr) {
0 => 'First case',
1, 2, 3 => multipleCases(),
default => 'Default case',
};
```

### 5.3 `while`, `do while`

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

0 comments on commit 89fbefa

Please sign in to comment.