diff --git a/about_structs.go b/about_structs.go new file mode 100644 index 0000000..b095ea5 --- /dev/null +++ b/about_structs.go @@ -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 +} diff --git a/setup_koans_test.go b/setup_koans_test.go index 7d4dc55..7081d88 100644 --- a/setup_koans_test.go +++ b/setup_koans_test.go @@ -28,10 +28,10 @@ func TestKoans(t *testing.T) { //testFiles() //testInterfaces() //testMaps() - testPointers() + //testPointers() + testStructs() // TODO: ie, gameplan - //testStructs() //testAllocation() //testGoroutines() //testChannels()