dev/vala/gobj_style_construction/main.vala

26 lines
519 B
Vala

public class Person : Object {
/* Construction properties */
public string name { get; construct; }
public int age { get; construct set; }
public Person(string name) {
Object(name: name);
}
public Person.with_age(string name, int years) {
Object(name: name, age:years);
}
construct {
// do anything else
stdout.printf("Welcome %s\n", this.name);
}
}
void main () {
var a = new Person("Kolan"),
b = new Person.with_age("Volodia", 30);
var c = Object.new (a.get_type(), "name", "Unnamed");
}