4 ms·
Just avoid trying to explain to a newbie that what closures are and that you can pass functions around. That normaly === "mind blow"
by fmsf 14y ago
Just avoid trying to explain to a newbie that what closures are and that you can pass functions around. That normaly === "mind blow"
- Tloewald 14y agoI suspect it's more likely to be "mind blow" for experienced programmers of less dynamic languages than novice programmers. Indeed, if you start by declaring functions as variables you're halfway there. The way you pass around functions in, say, PHP (or more accurately, the way PHP fakes it by using syntax sugar for eval) is a lot more confusing.
- damncabbage 14y agoPHP is terrible, but the following now is valid PHP: $addOne = function($a){ return $a + 1 }; $result = array_map($addOne, array(1,2,3)); // now [2,3,4] Or: // Reference to intval() function. $result = array_map(intval, array('1','2','a'));