CS153/hw6/hw5programs/ifq5.oat

18 lines
267 B
Text
Raw Normal View History

struct T { int x }
struct S { int x; int y }
int sum(S? s) {
if?(T t = s) {
return t.x;
} else {
return 0;
}
}
int program (int argc, string[] argv) {
var x = 0;
x = x + sum(S null);
x = x + sum(new S{x=4; y=5});
return x;
}