Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What methods and properties do Vala arrays support?

Tags:

vala

The Vala Tutorial mentions the following methods and properties (and operators) for built-in arrays:

arr.length
arr += element
arr.resize()
arr.move()

(By "built-in arrays" I mean ones like int[] arr = new int[5], in contrast to the fancy data structures provided by GLib or Gee.)

My question: do such arrays support any more methods and properties? Where is this documented?

like image 328
Niccolo M. Avatar asked May 13 '18 13:05

Niccolo M.


1 Answers

According to the compiler source code there should also be arr.copy():

https://gitlab.gnome.org/GNOME/vala/blob/master/vala/valaarraytype.vala

Also if you look at the unit tests you can see that slices (e.g. arr[1:5]) are a feature of arrays:

https://gitlab.gnome.org/GNOME/vala/blob/master/tests/basic-types/arrays.vala

But I think thats it. The built-in array is pretty minimalistic.

like image 100
Jens Mühlenhoff Avatar answered Oct 20 '22 14:10

Jens Mühlenhoff