v/vlib/v/fmt/tests/anon_fn_input.vv

24 lines
594 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 string, s2 string, 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')
}