aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/typedmethods.zc
blob: facd9f158f7e7be6d8e3c6cc0899a1892b07e2a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// struct methods declare a return type and typed parameters, like functions do
struct Str {
	int len;
	static int size(int s) { return s * 2; }
	int plus(int k) { return this.len + k; }
	static fn none() { return 5; }
}
int main() {
	Str a;
	a.len = 9;
	put_n(Str.size(7)); put_c(32);
	put_n(Str.none()); put_c(32);
	put_n(a.plus(4));
	put_c(10);
	return 0;
}