mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
23 lines
291 B
V
23 lines
291 B
V
struct Foo {
|
|
a int
|
|
b int
|
|
c int
|
|
}
|
|
|
|
struct Holder {
|
|
mut:
|
|
i int
|
|
}
|
|
|
|
fn add(mut h Holder) ?int {
|
|
h.i++
|
|
return h.i
|
|
}
|
|
|
|
fn test_struct_init_with_multiple_optionals() {
|
|
mut h := Holder{}
|
|
foo := Foo{add(mut h) or { 0 }, add(mut h) or { 0 }, add(mut h) or { 0 }}
|
|
|
|
assert foo == Foo{1, 2, 3}
|
|
}
|