v4 / vlib / v / checker / tests / match_generic_case_err.vv
22 lines · 19 sloc · 228 bytes · b51dfcfe7db5f9176e5217dbf45ff10fe83f0dca
Raw
1module main
2
3import strconv
4
5fn main() {
6 println(to_int('1'))
7 println(to_int(1))
8}
9
10fn to_int[T](v T) i64 {
11 return match typeof(v).name {
12 'string' {
13 strconv.atoi(v) or { 0 }
14 }
15 'int' {
16 v
17 }
18 else {
19 0
20 }
21 }
22}
23