Arrays
An array is an ordered collection of elements. In Duwa, an array is a type that represents arrays. It is used to represent a list of values.
Rules for arrays:
- All elements in an array must be of the same type.
- Arrays are zero-based, meaning the first element is at index
0
. - The size of an array is dynamic and can be changed at runtime.
- Arrays can be multidimensional.
Syntax
Accessing elements
You can access elements of an array using the index. The index starts at 0
.
Updating elements
You can update elements of an array using the index.
Examples usage
Methods
kutalika()→ number
Returns
number
Returns the number of elements in an array.
chotsaKumbuyo()→ any
Returns
any
Removes the last element from an array and returns that element. This method changes the length of the array.
Kankha()→ number
Returns
number
Adds one or more elements to the end of an array and returns the new length of the array.
chotsaKutsogolo()→ any
Returns
any
Removes the first element from an array and returns that element. This method changes the length of the array.