diff options
author | Indrajith K L | 2022-12-03 17:00:20 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-03 17:00:20 +0530 |
commit | f5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch) | |
tree | 2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/examples/compiletime/compile-time-for.v | |
download | cli-tools-windows-master.tar.gz cli-tools-windows-master.tar.bz2 cli-tools-windows-master.zip |
Diffstat (limited to 'v_windows/v/examples/compiletime/compile-time-for.v')
-rw-r--r-- | v_windows/v/examples/compiletime/compile-time-for.v | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/v_windows/v/examples/compiletime/compile-time-for.v b/v_windows/v/examples/compiletime/compile-time-for.v new file mode 100644 index 0000000..f3f90fa --- /dev/null +++ b/v_windows/v/examples/compiletime/compile-time-for.v @@ -0,0 +1,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('') + } +} |