This commit is contained in:
Steven Degutis
2012-03-16 08:18:18 -05:00
parent 6919de226f
commit 692e648de3
2 changed files with 26 additions and 2 deletions

24
about_structs.go Normal file
View File

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

View File

@@ -28,10 +28,10 @@ func TestKoans(t *testing.T) {
//testFiles() //testFiles()
//testInterfaces() //testInterfaces()
//testMaps() //testMaps()
testPointers() //testPointers()
testStructs()
// TODO: ie, gameplan // TODO: ie, gameplan
//testStructs()
//testAllocation() //testAllocation()
//testGoroutines() //testGoroutines()
//testChannels() //testChannels()