summaryrefslogtreecommitdiff
path: root/tests/control-flow/coalesce-reference-transfer.vala
blob: 4efbf3ed484695e434437ee52e2dafc797b533f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[Compact]
class Foo {
	public int i;

	public Foo (int i) {
		this.i = i;
	}
}

Foo? get_foo (int? i) {
	return i != null ? new Foo (i) : null;
}

void main () {
	{
		Foo foo = get_foo (null) ?? get_foo (42);
		assert (foo.i == 42);
	}
	{
		Foo foo = get_foo (null) ?? (get_foo (null) ?? get_foo (42));
		assert (foo.i == 42);
	}
}