Skip to content

Commit d00c9e8

Browse files
jasonmmlstrojny
authored andcommitted
Add note to docs about using curry with flip. (#206)
Closes #140.
1 parent 0f7d89c commit d00c9e8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/functional-php.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ $curriedAdd = curry('add');
475475
$curriedAdd(10)(5)(27)(10); // -> 52
476476
```
477477

478+
_Note, that you cannot use `curry` on a flipped function. `curry` uses reflection to get the number of function arguments, but this is not possible on the function returned from `flip`. Instead use `curry_n` on flipped functions._
479+
478480
## curry_n()
479481

480482
`curry` uses reflection to determine the number of arguments, which can be slow depdening on your requirements. Also, you might want to curry only the first parameters, or your function expects a variable number of parameters. In all cases, you can use `curry_n` instead.
@@ -772,7 +774,7 @@ var_dump($sum_of_range(1, 10000)); // 50005000;
772774
```
773775

774776
## flip()
775-
Return a new function with the argument order flipped. This can be useful when currying functions like `filter` to provide the data last.
777+
Return a new function with the argument order flipped. This can be useful when currying functions like `filter` to provide the data last.
776778

777779
```php
778780
use function Functional\flip;
@@ -787,6 +789,8 @@ var_dump($get_even([1, 2, 3, 4])); // [2, 4]
787789

788790
```
789791

792+
_Note, that you cannot use `curry` on a flipped function. `curry` uses reflection to get the number of function arguments, but this is not possible on the function returned from `flip`. Instead use `curry_n` on flipped functions._
793+
790794
## not
791795
Return a new function which takes the same arguments as the original function, but returns the logical negation of it's result.
792796

0 commit comments

Comments
 (0)