Skip to content

Commit df62590

Browse files
rodnaphlstrojny
authored andcommitted
add "not" function to documentation (lstrojny#161)
1 parent 8c33128 commit df62590

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/functional-php.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,22 @@ var_dump($get_even([1, 2, 3, 4])); // [2, 4]
742742

743743
```
744744

745+
## not
746+
Return a new function which takes the same arguments as the original function, but returns the logical negation of it's result.
747+
748+
```php
749+
use function Functional\not;
750+
751+
$is_even = function ($number) {
752+
return $number % 2 == 0;
753+
};
754+
$is_odd = not($is_even);
755+
756+
var_dump($is_odd(1)); // true
757+
var_dump($is_odd(2)); // false
758+
759+
```
760+
745761
## Other
746762

747763
`mixed Functional\memoize(callable $callback[, array $arguments = []], [mixed $key = null]])`

0 commit comments

Comments
 (0)