CS153/hw5/hw5programs/tc_struct_null_field.oat

19 lines
225 B
Text
Raw Normal View History

struct A {
int x
}
struct B {
A? a /* can be null */
}
int program(int argc, string[] args) {
var b = new B{a=A null};
b.a = new A{x = 3};
if? (A a2 = b.a) {
return a2.x;
}
b.a = A null;
return 0;
}