I'm new to Vala and trying to understand how the language works. I usually use script languages like Python or JavaScript.
So, my question is why are there three ways of class constructor definition and how does the GObject style constructor work?
For the best understanding lets make an analogy with python:
Python class definition
class Car(object):
speed: int
def __init__(self, speed): # default constructor
self.speed = speed # property
And Vala
class Car : GLib.Object {
public int speed { get; construct; }
// default
internal Car(int speed) {
Object(speed: speed)
}
construct {} // another way
}
I was reading the Vala tutorial section about GObject style construction, but still do not understand how Object(speed: speed)
works and for what construct
is needed?