package main // Anonymous inclusion of one structure within another // When this is done, if a name is reused, you can get // "hidden" variables (as ia) below. You can get to the // hidden variable through the name of the structure containing // the hidden // // Note that even with anonymous includes, you still need to // say the name of the struct during initialization // G Towell // July 2022 import "fmt" type Aa struct { ia int fb float32 } type Bb struct { Aa ia int } func (this Bb) String() string { return fmt.Sprintf("aia:%v afb:%v bia:%v", this.Aa.ia, this.fb, this.ia) } func main() { aa := Aa{1,2} ba := Bb{Aa{3,4.0},5} fmt.Printf("%v\n", aa) fmt.Printf("%v\n", ba) }