Module : lang.array

Module Overview

This module provides lang library list operations defined by the language specification 2019R3.

Objects

$anonType$1

Functions

enumerate

Returns a new array consisting of index and member pairs.

filter

Selects the members from an array for which a function returns true.

forEach

Applies a function to each member of an array. The function func is applied to each member of array arr in order.

fromBase16

Returns the byte array that a string represents in Base16. str must consist of the characters 0..9, A..F, a..f and whitespace as allowed by a Ballerina Base16Literal.

fromBase64

Returns the byte array that a string represents in Base64. str must consist of the characters A..Z, a..z, 0..9, +, /, = and whitespace as allowed by a Ballerina Base64Literal.

indexOf

Returns the index of first member of arr that is equal to val if there is one. Returns () if not found Equality is tested using ==

iterator

Returns an iterator over an array.

length

Returns the number of members of an array.

map

Applies a function to each member of an array and returns an array of the results.

pop

Removes and returns the last member of an array. The array must not be empty.

push

Adds values to the end of an array.

reduce

Combines the members of an array using a combining function. The combining function takes the combined value so far and a member of the array, and returns a new combined value.

remove

Removes a member of an array.

removeAll

Removes all members of an array.

reverse

Reverses the order of the members of an array.

setLength

Changes the length of an array.

shift

Removes and returns first member of an array. The array must not be empty.

slice

Returns a subarray starting from startIndex (inclusive) to endIndex (exclusive).

sort

Sorts an array using a comparator function. The comparator function must return a value less than, equal to or greater than zero according as its first argument is to be ordered before, equal to or after its second argument.

toBase16

Returns the string that is the Base16 representation of an array of bytes. The representation is the same as used by a Ballerina Base16Literal. The result will contain only characters 0..9, a..f. There will be no whitespace in the returned string.

toBase64

Returns the string that is the Base64 representation of an array of bytes. The representation is the same as used by a Ballerina Base64Literal. The result will contain only characters A..Z, a..z, 0..9, +, / and =. There will be no whitespace in the returned string.

unshift

Adds values to the start of an array. The values newly added to the array will be in the same order as they are in vals.