github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/struct50b.gno (about)

     1  package main
     2  
     3  type Node struct {
     4  	Name  string
     5  	Child []Node
     6  }
     7  
     8  func main() {
     9  	a := Node{Name: "hello"}
    10  	a.Child = append([]Node{}, Node{Name: "world"})
    11  	println(a)
    12  	a.Child[0].Child = append([]Node{}, Node{Name: "sunshine"})
    13  	println(a)
    14  }
    15  
    16  // Output:
    17  // (struct{("hello" string),(slice[(struct{("world" string),(nil []main.Node)} main.Node)] []main.Node)} main.Node)
    18  // (struct{("hello" string),(slice[(struct{("world" string),(slice[(struct{("sunshine" string),(nil []main.Node)} main.Node)] []main.Node)} main.Node)] []main.Node)} main.Node)