Skip to content

Commit e4c8ba3

Browse files
committed
Update problem file
1 parent bd02ba4 commit e4c8ba3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

exercises/unite-the-types/problem/problem.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ In the process you should create a function named `adder` which accepts these nu
66

77
The type of the parameter should be a union of all the types of numbers we might pass to your program.
88

9-
We will pass to your program any number of random numbers which could be integers, floats or strings. Your `adder` function
10-
should only accept these types.
9+
We will pass to your program any amount of random numbers which could be integers, floats or strings. Your `adder` function
10+
should only accept these types. Regardless of the type, every argument will be a number.
1111

1212
You should output the sum of the numbers followed by a new line.
1313

1414
How you print and add the numbers is up to you.
1515

16-
### The advantages of match
16+
### The advantages of union types
1717

18-
* Match uses strict equality, unlike switch which uses weak comparison and can lead to subtle bugs.
19-
* Each match arm does not fall through without a break statement, unlike switch.
20-
* Match expressions must be exhaustive, if there is no default arm specified, and no arm matches the given value, an `UnhandledMatchError` is thrown
21-
* Match is an expression and thus returns a value, reducing unnecessary variables and reducing the risk of accessing undefined variables.
18+
* Allows us to represent more complex types in a simpler manner, such as the pseudo `Number` type we are inventing here in this exercise.
19+
* The types are enforced by PHP so `TypeError`'s will be thrown when attempting to pass non-valid types.
20+
* Allows us to move information from phpdoc into function signatures.
21+
* It prevents incorrect function information. phpdocs can often go stale when they are not updated with the function itself.
2222

2323

2424
----------------------------------------------------------------------
2525
## HINTS
2626

2727
Remember the first argument will be the programs file path and not an argument passed to the program.
2828

29-
The function must be called `adder`.
29+
The function you implement must be called `adder`.
3030

3131
It is up to you to pass the numbers to your function.
3232

33-
Documentation on the union types can be found by pointing your browser here:
33+
Documentation on union types can be found by pointing your browser here:
3434
[https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.union]()
3535

3636
----------------------------------------------------------------------

0 commit comments

Comments
 (0)