Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 822 Bytes

array-functions.md

File metadata and controls

68 lines (47 loc) · 822 Bytes
version example_title
1.0.0
Array Functions

Array Functions

repeat

Syntax

array.repeat(number type)

Makes an array with the given element number of times.

foo := [1, 2].repeat(5)
println(foo) // [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]

delete

Syntax

array.delete(ix type)

Deletes the element present in the array at index ix.

mut even_numbers := [2, 4, 6, 8, 10]
even_numbers.delete(3)
println(even_numbers) // [2, 4, 6, 10]

reverse

Syntax

array.reverse()

Reverses the array.

float_num := [1.1, 1.3, 1.25, 1.4]
float_num.reverse() // [1.4, 1.25, 1.3, 1.1]

clone

Syntax

array.clone()

Clones and returns a new array.

foo := [1, 2, 4, 5, 4, 6]
foo1 := foo.clone()
println(foo1) // [1, 2, 4, 5, 4, 6]