Search…
Array Functions

repeat

Syntax
1
array.repeat(number int)
Copied!
Makes an array with the given element number of times.
1
foo := [1, 2].repeat(5)
2
println(foo)
Copied!
Output
1
[1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
Copied!

delete

Syntax
1
array.delete(ix int)
Copied!
Deletes the element present in the array at index ix.
1
mut even_numbers := [2, 4, 6, 8, 10]
2
even_numbers.delete(3)
3
println(even_numbers)
Copied!
Output
1
[2, 4, 6, 10]
Copied!

reverse

Syntax
1
array.reverse()
Copied!
Reverses the array.
1
float_num := [1.1, 1.3, 1.25, 1.4]
2
float_num.reverse()
Copied!
Output
1
[1.4, 1.25, 1.3, 1.1]
Copied!

clone

Syntax
1
array.clone()
Copied!
Clones and returns a new array.
1
foo := [1, 2, 4, 5, 4, 6]
2
foo1 := foo.clone()
3
println(foo1)
Copied!
Output
1
[1, 2, 4, 5, 4, 6]
Copied!
Last modified 2yr ago
Copy link