v2 / vlib / v / tests / options / option_fn_multi_ret_test.v
23 lines · 19 sloc · 294 bytes · 65a5e968d713dd795152b55e64981bd6b63bf22d
Raw
1module main
2
3type Cmd = fn () string
4
5fn cplx() (bool, ?Cmd) {
6 return true, stringer
7}
8
9fn stringer() string {
10 return 'a string'
11}
12
13fn test_main() {
14 mut cmd := ?Cmd(none)
15 mut truth := false
16 truth, cmd = cplx()
17 if cmd != none {
18 println(cmd())
19 assert true
20 } else {
21 assert false
22 }
23}
24