You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is a lot like #412. In https://tour.golang.org/moretypes/9 there is usage of an anonymous struct. This is the first time a new comer is introduced to the concept that a composite type may be informally declared.
"Structs may be declared inline and without a name if the need arises for a one time use structure."
package main
import"fmt"funcmain() {
fmt.Println(struct{Greeting, Planetstring}{"Hello", "World"})
}
The pros to including this explanation is that users are not caught off guard when they find it elsewhere in the tour or in the wild. The cons are that it may encourage less than perfectly idiomatic go code, but if that were the case the allowance of their existence in the spec is suspect.
Happy to create this if you guys would like :)
The text was updated successfully, but these errors were encountered:
mattc41190
changed the title
Anonymous Struct Not Explained
tour: Anonymous Struct Not Explained
Jan 24, 2019
This issue is a lot like #412. In https://tour.golang.org/moretypes/9 there is usage of an anonymous struct. This is the first time a new comer is introduced to the concept that a composite type may be informally declared.
As a suggestion I would add this after https://tour.golang.org/moretypes/5 with the following simple explanation:
"Structs may be declared inline and without a name if the need arises for a one time use structure."
The pros to including this explanation is that users are not caught off guard when they find it elsewhere in the tour or in the wild. The cons are that it may encourage less than perfectly idiomatic go code, but if that were the case the allowance of their existence in the spec is suspect.
Happy to create this if you guys would like :)
The text was updated successfully, but these errors were encountered: