File: property-struct.vala

package info (click to toggle)
vala 0.56.18-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 57,528 kB
  • sloc: ansic: 581,293; sh: 5,357; makefile: 3,980; xml: 3,161; yacc: 1,219; lex: 374; javascript: 23
file content (30 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
struct Bar {
	public string s;
	public int i;
}

struct Baz : Bar {
}

class Foo : Object {
	public Bar foo { get; set; }
	public Bar bar { owned get; owned set; }
	public Baz faz { get; set; }
	public Baz baz { owned get; owned set; }
}

void main () {
	var foo = new Foo ();
	foo.bar = { "bar", 23 };
	assert (foo.bar.s == "bar");
	assert (foo.bar.i == 23);
	foo.foo = { "foo", 42 };
	assert (foo.foo.s == "foo");
	assert (foo.foo.i == 42);
	foo.baz = { "baz", 4711 };
	assert (foo.baz.s == "baz");
	assert (foo.baz.i == 4711);
	foo.faz = { "faz", 72 };
	assert (foo.faz.s == "faz");
	assert (foo.faz.i == 72);
}