4 ms·
1: But does the syntax really collide? I would think that this: $a=[ 'doubler' => $x => $x*2 ] clearly should create an array with an elemnt that is a fu
by FreeHugs 7y ago
1: But does the syntax really collide?
I would think that this:
$a=[ 'doubler' => $x => $x*2 ]
clearly should create an array with an elemnt that is a function and has the key 'doubler'. Where is the problem?
2: And how about just using some other char combination?
$x ~> $x * 2
Or something like that.
- simion314 7y agoIsn't readability more important then typing a few less characters? We spend more time reading the code so readability is more important IMO.
- francislavoie 7y agoIt's all covered here in the discussion section: https://wiki.php.net/rfc/arrow_functions_v2 https://wiki.php.net/rfc/arrow_functions_v2
- jorams 7y ago> But does the syntax really collide? Yes. $a = [ $x => $x * 2 ]; Is this an array mapping the key $x to the value $x * 2, or is this an array mapping the key 0 to a function that doubles its input?