• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/03_stdlib/68_shift

  1 The `shift()` function removes the first element of the given source array.
  2 
  3 Returns the removed value.
  4 
  5 Returns `null` if the given source argment is not an array.
  6 
  7 Throws a type exception if the given array is immuatable.
  8 
  9 -- Testcase --
 10 {%
 11         let arr = [ 1, null, 3 ];
 12 
 13         printf("%.J\n", [
 14                 // remove one element
 15                 shift(arr),
 16 
 17                 // remove a null element
 18                 shift(arr),
 19 
 20                 // invalid source
 21                 shift({ test: true })
 22         ]);
 23 
 24         printf("%.J\n", arr);
 25 %}
 26 -- End --
 27 
 28 -- Expect stdout --
 29 [
 30         1,
 31         null,
 32         null
 33 ]
 34 [
 35         3
 36 ]
 37 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt