aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/examples/compiletime/compile-time-for.v
blob: f3f90fa6737e3b12503f523ec5a043e96a3bdd0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
struct App {}

fn (mut app App) method_one() {}

fn (mut app App) method_two() int {
	return 0
}

fn (mut app App) method_three(s string) string {
	return s
}

fn main() {
	$for method in App.methods {
		$if method.typ is fn (string) string {
			println('$method.name IS `fn(string) string`')
		} $else {
			println('$method.name is NOT `fn(string) string`')
		}
		$if method.return_type !is int {
			println('$method.name does NOT return `int`')
		} $else {
			println('$method.name DOES return `int`')
		}
		$if method.args[0].typ !is string {
			println("$method.name's first arg is NOT `string`")
		} $else {
			println("$method.name's first arg IS `string`")
		}
		// TODO: Double inversion, should this even be allowed?
		$if method.typ is fn () {
			println('$method.name IS a void method')
		} $else {
			println('$method.name is NOT a void method')
		}
		println('')
	}
}