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

Sources/ucode/tests/custom/03_stdlib/65_push

  1 The `push()` function appends the given argument(s) to the end of the given array
  2 while maintaining their order.
  3 
  4 Returns the last pushed value.
  5 
  6 Returns `null` if the given destination argment is not an array.
  7 
  8 Throws a type exception if the given array is immuatable.
  9 
 10 -- Testcase --
 11 {%
 12         let arr = [];
 13 
 14         printf("%.J\n", [
 15                 // push one element
 16                 push(arr, 123),
 17 
 18                 // push multiple elements
 19                 push(arr, 1, 2, 3),
 20 
 21                 // push null values
 22                 push(arr, null, null, 4),
 23 
 24                 // push no-op
 25                 push(arr),
 26 
 27                 // push with invalid destination
 28                 push({}, 1, 2, 3)
 29         ]);
 30 
 31         printf("%.J\n", arr);
 32 %}
 33 -- End --
 34 
 35 -- Expect stdout --
 36 [
 37         123,
 38         3,
 39         4,
 40         null,
 41         null
 42 ]
 43 [
 44         123,
 45         1,
 46         2,
 47         3,
 48         null,
 49         null,
 50         4
 51 ]
 52 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt