mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
20 lines
238 B
V
20 lines
238 B
V
struct Foo {
|
|
x int
|
|
}
|
|
|
|
struct Bar {}
|
|
|
|
type FooBar = Bar | Foo
|
|
|
|
struct Abc {
|
|
foobar FooBar = Foo{
|
|
x: 123
|
|
}
|
|
}
|
|
|
|
fn test_struct_field_default_value_sumtype_cast() {
|
|
x := Abc{}
|
|
assert x.foobar is Foo
|
|
assert (x.foobar as Foo).x == 123
|
|
}
|