1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/tests/if_expr_with_result_test.v

18 lines
274 B
V

fn foo(i int) ?bool {
return if i == 0 { true } else { none }
}
fn bar(i int) !bool {
return if i == 0 { true } else { error('') }
}
fn test_if_expr_with_result() {
r1 := foo(0) or { false }
println(r1)
assert r1
r2 := bar(0) or { false }
println(r2)
assert r2
}