Skip to content

Commit 6d93490

Browse files
committed
Fix new lines
1 parent 7732ca6 commit 6d93490

File tree

1 file changed

+3
-5
lines changed
  • exercises/a-match-made-in-heaven/problem

1 file changed

+3
-5
lines changed

exercises/a-match-made-in-heaven/problem/problem.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
You have been given a piece of code (look for `a-match-made-in-heaven.php` in your working directory) which is full of bugs.
2-
The code has been implemented badly, using a `switch` statement. Your job is to fix the code, by using the newly introduced
3-
`match` expression in PHP 8.
2+
The code has been implemented badly, using a `switch` statement. Your job is to fix the code, by using the newly introduced `match` expression in PHP 8.
43

54
The piece of code is supposed to take a string representing a keyboard keypress and convert it to its equivalent ANSI decimal code.
65

76
There are only four key presses supported at the minute (enter, up, down & escape). It should stay like that for now.
87

98
Focus on converting the switch statement to a match expression.
109

11-
The key presses will be provided as strings via command line arguments. Only one keypress will be passed on each program invocation
12-
but it will be randomly picked from the four supported key presses.
10+
The key presses will be provided as strings via command line arguments. Only one keypress will be passed on each program invocation but it will be randomly picked from the four supported key presses.
1311

1412
### The advantages of match
1513

1614
* Match uses strict equality, unlike switch which uses weak comparison and can lead to subtle bugs.
1715
* Each match arm does not fall through without a break statement, unlike switch.
18-
* Match expressions must be exhaustive, if there is no default arm specified, and no arm matches the given value, an `UnhandledMatchError` is thrown
16+
* Match expressions must be exhaustive, if there is no default arm specified, and no arm matches the given value, an `UnhandledMatchError` is thrown.
1917
* Match is an expression and thus returns a value, reducing unnecessary variables and reducing the risk of accessing undefined variables.
2018

2119

0 commit comments

Comments
 (0)