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