GObject Style Construction...
This commit is contained in:
parent
7d5300f6dc
commit
3f3c1b1d59
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* Bounds of the ``ATable`` to split.
|
||||
*/
|
||||
public struct SplitLimit {
|
||||
|
||||
/**
|
||||
* First column index [0; last].
|
||||
*/
|
||||
uint first;
|
||||
|
||||
/**
|
||||
* Last column index [first; ncols - 1].
|
||||
*/
|
||||
uint last;
|
||||
|
||||
/**
|
||||
* Maximum of columns per page [1; ncols].
|
||||
*/
|
||||
uint max_cols;
|
||||
}
|
||||
|
||||
void print_list (List<SplitLimit?> array) {
|
||||
for (var i = 0; i < array.length(); ++i) {
|
||||
stdout.printf ("%lu %lu %lu\n", array.nth(i).data.first,
|
||||
array.nth(i).data.last, array.nth(i).data.max_cols);
|
||||
}
|
||||
}
|
||||
|
||||
void main () {
|
||||
var array = new List<SplitLimit?> ();
|
||||
SplitLimit lim = { 9, 11, 3 };
|
||||
array.append (lim);
|
||||
lim = { 2, 6, 2 };
|
||||
array.append (lim);
|
||||
lim = { 13, 16, 1 };
|
||||
array.append (lim);
|
||||
//array.append ("ccc");
|
||||
//array.append ("aaa");
|
||||
//array.append ("bbb");
|
||||
|
||||
print_list (array);
|
||||
|
||||
stdout.puts ("--------\n");
|
||||
|
||||
array.sort ((a, b) => {
|
||||
stdout.printf ("a.first=%lu\n", a.first);
|
||||
if (a.first < b.first) return -1;
|
||||
if (a.first > b.first) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
stdout.puts ("--------\n");
|
||||
|
||||
print_list (array);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
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");
|
||||
}
|
Loading…
Reference in New Issue