mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
25 lines
552 B
V
25 lines
552 B
V
fn has_anon_fn() {
|
|
an_fn := fn () {
|
|
println('Hello there !')
|
|
}
|
|
an_fn_w_param := fn (s string) {
|
|
println('I received $s')
|
|
}
|
|
an_fn_w_multi_params := fn (s1, s2, s3 string) {
|
|
println('I received $s1, $s2, $s3')
|
|
}
|
|
an_fn_w_multi_params2 := fn (s string, i int) {
|
|
println('I received $s, $i')
|
|
}
|
|
fn_w_var_args := fn (ss ...string) {
|
|
for s in ss {
|
|
println('yo $s')
|
|
}
|
|
}
|
|
an_fn()
|
|
an_fn_w_param('a gift')
|
|
an_fn_w_multi_params('one', 'two', 'three')
|
|
an_fn_w_multi_params2('one', 1)
|
|
fn_w_var_args('one arg', 'two args', 'three args')
|
|
}
|