enumeration

This commit is contained in:
Steven Degutis
2012-03-16 07:00:35 -05:00
parent 2f82968554
commit c2a8b55d70

28
about_enumeration.go Normal file
View File

@@ -0,0 +1,28 @@
package go_koans
func testEnumeration() {
{
var concatenated string
var total int
strings := []string{"hello", " world", "!"}
for i, v := range strings {
total += i
concatenated += v
}
assert(concatenated == __string__) // for loops have a modern variation
assert(total == __int__) // which offers both a value and an index
}
{
var totalLength int
strings := []string{"hello", " world", "!"}
for _, v := range strings {
totalLength += len(v)
}
assert(totalLength == __int__) // although we may omit either value
}
}