Created
January 10, 2015 01:18
-
-
Save sgolemon/50425dffc0ed09cf2cc5 to your computer and use it in GitHub Desktop.
Short Lambda Syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$names = ['Alice', 'Bob']; | |
// PHP Closures | |
$greetings = array_map( | |
function($x) { | |
return "Hello $x"; | |
}, $names); | |
// HHVM's short-lambda version | |
$greetings = array_map($x ==> "Hello $x", $names); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or you can do the same thing, without having to expose your codebase to eval: