rfc:spread_operator_for_array

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:spread_operator_for_array [2019/04/04 13:55] – v0.2 jhdxrrfc:spread_operator_for_array [2019/04/05 06:09] jhdxr
Line 31: Line 31:
 ==== String keys ==== ==== String keys ====
  
-In order to make the behavior consistent with [[rfc:argument_unpacking|argument unpacking]], string keys are not supported.+In order to make the behavior consistent with [[rfc:argument_unpacking|argument unpacking]], string keys are not supported. A recoverable error will be thrown once a string key is encountered.
  
 ==== By-reference passing ==== ==== By-reference passing ====
Line 37: Line 37:
 <code php> <code php>
 $arr1 = [1, 2, 3]; $arr1 = [1, 2, 3];
-$arr2 = [...&$arr1]; //invalid+$arr2 = [...&$arr1]; //invalid syntax
 </code> </code>
  
Line 68: Line 68:
   - ''array_merge'' only supports array, while spread operator also supportes objects implementing ''Traversable''   - ''array_merge'' only supports array, while spread operator also supportes objects implementing ''Traversable''
  
-==== ''...'' should be preserved for other use (e.g. map concat) ====+==== ... should be preserved for other use (e.g. map concat) ====
 This is kind of out of scope here to discuss other concat / merge operation. The important thing is we should make the behavior of same operator consistent and not to confuse userland developer. It's also why I changed the behavior for string keys in this revised version. This is kind of out of scope here to discuss other concat / merge operation. The important thing is we should make the behavior of same operator consistent and not to confuse userland developer. It's also why I changed the behavior for string keys in this revised version.
  
rfc/spread_operator_for_array.txt · Last modified: 2019/05/13 12:45 by nikic