Permalink
Browse files

Merge pull request #98 from skrul/coalesced-parameters

Complete TODO for coalesced function parameters.
  • Loading branch information...
2 parents de90934 + abcd36f commit 446bd9fb2ce01d08285242f94e6650b7547fd8ce @mmcgrana committed Feb 25, 2015
Showing with 12 additions and 2 deletions.
  1. +11 −2 examples/functions/functions.go
  2. +1 −0 examples/functions/functions.sh
View
13 examples/functions/functions.go
@@ -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
1 examples/functions/functions.sh
@@ -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.

0 comments on commit 446bd9f

Please sign in to comment.