summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/03_stdlib/68_shift
blob: 7b0df89e3eacbdfc45eee3f458cd86deae03079d (plain)
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
The `shift()` function removes the first element of the given source array.

Returns the removed value.

Returns `null` if the given source argment is not an array.

Throws a type exception if the given array is immuatable.

-- Testcase --
{%
	let arr = [ 1, null, 3 ];

	printf("%.J\n", [
		// remove one element
		shift(arr),

		// remove a null element
		shift(arr),

		// invalid source
		shift({ test: true })
	]);

	printf("%.J\n", arr);
%}
-- End --

-- Expect stdout --
[
	1,
	null,
	null
]
[
	3
]
-- End --