Complete TODO for coalesced function parameters.

This commit is contained in:
Steve Krulewitz 2015-02-24 14:54:33 -08:00
parent 6494e4478b
commit abcd36fec0
2 changed files with 12 additions and 2 deletions

View File

@ -15,12 +15,21 @@ func plus(a int, b int) int {
return a + b
}
// When you have multiple consecutive parameters of
// the same type, you may omit the type name for the
// like-typed parameters up to the final parameter that
// declares the type.
func plusPlus(a, b, c int) int {
return a + b + c
}
func main() {
// Call a function just as you'd expect, with
// `name(args)`.
res := plus(1, 2)
fmt.Println("1+2 =", res)
}
// todo: coalesced parameter types
res = plusPlus(1, 2, 3)
fmt.Println("1+2+3 =", res)
}

View File

@ -1,5 +1,6 @@
$ go run functions.go
1+2 = 3
1+2+3 = 6
# There are several other features to Go functions. One is
# multiple return values, which we'll look at next.