vlang

Can there be more than one struct member per line?


Can I have more than one struct member per line?

I was making a struct. It seems like V enforces only one member per line. I don't recall seeing that mentioned anywhere.

trial.v:191:2: error: unknown type `` 
  189 |     fsize    int
  190 |     vers     int
  191 |     x,y,z    i16
      |     ~~
  192 |     c    int

Solution

  • It looks like you cannot use the comma shortcut in field declarations. For example, the following works:

    struct S { x int y int z f32 }
    
    fn main() {
        s := S { x: 10 y: 20 z: 3.14 }
    }