1 | struct App {} |
2 | |
3 | fn (mut app App) method_one() {} |
4 | |
5 | fn (mut app App) method_two() int { |
6 | return 0 |
7 | } |
8 | |
9 | fn (mut app App) method_three(s string) string { |
10 | return s |
11 | } |
12 | |
13 | fn main() { |
14 | $for method in App.methods { |
15 | $if method.typ is fn (string) string { |
16 | println('${method.name} IS `fn(string) string`') |
17 | } $else { |
18 | println('${method.name} is NOT `fn(string) string`') |
19 | } |
20 | $if method.return_type !is int { |
21 | println('${method.name} does NOT return `int`') |
22 | } $else { |
23 | println('${method.name} DOES return `int`') |
24 | } |
25 | $if method.args[0].typ !is string { |
26 | println("${method.name}'s first arg is NOT `string`") |
27 | } $else { |
28 | println("${method.name}'s first arg IS `string`") |
29 | } |
30 | // TODO: Double inversion, should this even be allowed? |
31 | $if method.typ is fn () { |
32 | println('${method.name} IS a void method') |
33 | } $else { |
34 | println('${method.name} is NOT a void method') |
35 | } |
36 | println('') |
37 | } |
38 | } |