5 ms·
But does it have to be =>? How about ~>? $a=[$x ~> $x*2, $x ~> $x*$x]; $a[1](5); // 25 Looks cool to me.
by Freegile 7y ago
But does it have to be =>? How about ~>?
$a=[$x ~> $x*2, $x ~> $x*$x];
$a[1](5); // 25
Looks cool to me.
- johannes1234321 7y ago~ is annoying to type on some keyboard layouts (Alt Gr and + onna German keyboard) Also PHP tries to be "googlable". Typing "fn PHP" into Google should bring relevant hits, for people never seen such a construct.
- _wolfie_ 7y ago> Also PHP tries to be "googlable". If not insisting on the "google" part, there always is http://symbolhound.com/?q=php+%7E%3E http://symbolhound.com/?q=php+%7E%3E
- mcovey 7y agoI noticed lately google is starting to understand symbols in certain contexts. Searching "php =>" actually does provide relevant results.
- asdasdasdasdwd 7y agoThere's some rationale here[0]. Basically they'd need to use a parser that on ambiguities would have to go down all possible routes concurrently until all but one fail, which can lead to performance costs. Using a prefix keeps things simple. [0] https://wiki.php.net/rfc/arrow_functions_v2#x_x_y1 https://wiki.php.net/rfc/arrow_functions_v2#x_x_y1