note 125357 added to migration70.new-features
| From: | JulianSawicki@php.net | Date: | Sat, 12 Sep 2020 14:30:30 +0000 |
| Subject: | note 125357 added to migration70.new-features | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-215106@lists.php.net to get a copy of this message | ||
Currying was possible in php 5.6. But in php 7.0 it is now possible to invoke a curryied function
with a one liner.
<?php
// A curried function
function add($a) {
return function($b) use ($a) {
return $a + $b;
};
}
// Invoking a curried function in PHP 7
$result = add(10)(15);
var_dump($result); // int 25
// Invoking a curried function in PHP 5.6
$add10 = add(10);
$result = $add10(15);
var_dump($result); // int 25
?>
----
Server IP: 45.112.84.4
Probable Submitter: 103.51.167.36 (proxied: 82.197.213.176)
----
Manual Page -- http://php.net/manual/en/migration70.new-features.php
Edit -- https://master.php.net/note/edit/125357
Del: integrated -- https://master.php.net/note/delete/125357/integrated
Del: useless -- https://master.php.net/note/delete/125357/useless
Del: bad code -- https://master.php.net/note/delete/125357/bad+code
Del: spam -- https://master.php.net/note/delete/125357/spam
Del: non-english -- https://master.php.net/note/delete/125357/non-english
Del: in docs -- https://master.php.net/note/delete/125357/in+docs
Del: other reasons-- https://master.php.net/note/delete/125357
Reject -- https://master.php.net/note/reject/125357
Search -- https://master.php.net/manage/user-notes.php