rfc:list_default_value

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
rfc:list_default_value [2015/11/09 13:54] reezerfc:list_default_value [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 15: Line 15:
 ===== Proposal ===== ===== Proposal =====
  
-Support new syntax to set default value for list elements, when there the requested index it not found in array:+Support new syntax to set default values for list elements, when the requested index it is not found in array:
  
 <code php> <code php>
Line 22: Line 22:
 list($a, $b='default') = [1, 2];  // a = 1, b = 2 list($a, $b='default') = [1, 2];  // a = 1, b = 2
  
-//  comparation +//  comparation  
-list($a, list($b=1, $c=2) = $arr;+list($a, list($b=1, $c=2)) = $arr;
 // or we need to check it ourself // or we need to check it ourself
 if (!isset($arr[1][0])) { if (!isset($arr[1][0])) {
Line 32: Line 32:
 } }
  
-$list($a, list($b, $c)) = $arr;+list($a, list($b, $c)) = $arr;
  
  
Line 51: Line 51:
 <code php> <code php>
  
-list($a, $b='deafult') = $arr;+list($a, $b='default') = $arr;
  
 // equals // equals
rfc/list_default_value.1447077278.txt.gz · Last modified: 2017/09/22 13:28 (external edit)