v icon indicating copy to clipboard operation
v copied to clipboard

anonymous struct can be assigned to a typed struct

Open larpon opened this issue 3 years ago • 0 comments

struct Message {
    a string
    b string
}

struct Fax {
    message Message
}

f := Fax{
    message: struct {
        a: 'A'
    }
}

dump(f)

Here, message can be assigned as an anonymous struct: message: struct { ... }?

Outputs:

[example.v:16] f: Fax{
    message: Message{
        a: 'A'
        b: ''
    }
}

Discord reference

larpon avatar Sep 01 '22 12:09 larpon