v2 / vlib / v / tests / fns / fn_call_generic_array_arg_test.v
15 lines · 13 sloc · 191 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1fn f64_fun(x []f64) f64 {
2 return x[0] + x[1]
3}
4
5fn t_fun[T](x []T) T {
6 $if T is f64 {
7 return f64_fun(x)
8 } $else {
9 return T(0)
10 }
11}
12
13fn test_main() {
14 assert t_fun([1.0, 2.0]) == 3.0
15}
16