Files
go-koans/about_structs.go
Tommy Parnell a7d91efcfc finished woo
2017-07-08 01:22:34 -04:00

25 lines
442 B
Go

package go_koans
func aboutStructs() {
var bob struct {
name string
age int
}
bob.name = "bob"
bob.age = 30
assert(bob.name == "bob") // structs are collections of named variables
assert(bob.age == 30) // each field has both setter and getter behavior
type person struct {
name string
age int
}
var john person
john.name = "bob"
john.age = 30
assert(bob == john) // assuredly, bob is certainly not john.. yet
}