v2 / vlib / v / checker / tests / option_in_operator_err.vv
23 lines · 19 sloc · 281 bytes · 3ef219a7c65b2025588929c6407bd5832aebccfd
Raw
1struct Item {
2 owner_id ?string
3}
4
5fn get_opt() ?int {
6 return 1
7}
8
9fn main() {
10 item := Item{
11 owner_id: 'key'
12 }
13 arr := [1, 2, 3]
14 m := {
15 'key': 1
16 }
17
18 // Optional struct field with map
19 _ = item.owner_id in m
20
21 // Optional function return with array
22 _ = get_opt() in arr
23}
24