This commit is contained in:
Steven Degutis
2012-03-17 12:47:22 -05:00
parent b40f5098bb
commit 86c1b13013
2 changed files with 14 additions and 0 deletions

13
about_types.go Normal file
View File

@@ -0,0 +1,13 @@
package go_koans
type coolNumber int
func (cn coolNumber) double() int {
return int(cn) * 2
}
func aboutTypes() {
i := coolNumber(4)
assert(i == coolNumber(__int__)) // values can be converted between compatible types
assert(i.double() == __int__) // you can add methods on any type you define
}

View File

@@ -22,6 +22,7 @@ func TestKoans(t *testing.T) {
aboutStrings()
aboutArrays()
aboutSlices()
aboutTypes()
aboutControlFlow()
aboutEnumeration()
aboutAnonymousFunctions()