@@ -6,31 +6,31 @@ In the process you should create a function named `adder` which accepts these nu
6
6
7
7
The type of the parameter should be a union of all the types of numbers we might pass to your program.
8
8
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.
11
11
12
12
You should output the sum of the numbers followed by a new line.
13
13
14
14
How you print and add the numbers is up to you.
15
15
16
- ### The advantages of match
16
+ ### The advantages of union types
17
17
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.
22
22
23
23
24
24
----------------------------------------------------------------------
25
25
## HINTS
26
26
27
27
Remember the first argument will be the programs file path and not an argument passed to the program.
28
28
29
- The function must be called ` adder ` .
29
+ The function you implement must be called ` adder ` .
30
30
31
31
It is up to you to pass the numbers to your function.
32
32
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:
34
34
[ https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.union ] ( )
35
35
36
36
----------------------------------------------------------------------
0 commit comments