Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
30
Task/Metaprogramming/V-(Vlang)/metaprogramming.v
Normal file
30
Task/Metaprogramming/V-(Vlang)/metaprogramming.v
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
@[heap]
|
||||
struct Foo {
|
||||
}
|
||||
|
||||
fn (f Foo) test() int {
|
||||
return 123
|
||||
}
|
||||
|
||||
fn (f Foo) test2() string {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo := Foo{}
|
||||
|
||||
$if ios || android {println("Running on a mobile device!")}
|
||||
$if linux && x64 {println("64-bit Linux.")}
|
||||
os := $if windows {"Windows"} $else {"Something Else"}
|
||||
println("Using ${os}")
|
||||
|
||||
$for m in Foo.methods {
|
||||
$if m.return_type is int {
|
||||
print("${m.name} returns int: ")
|
||||
println(foo.$method())
|
||||
} $else $if m.return_type is string {
|
||||
print("${m.name} returns string: ")
|
||||
println(foo.$method())
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue