Merge pull request #98 from skrul/coalesced-parameters
Complete TODO for coalesced function parameters.
This commit is contained in:
commit
446bd9fb2c
@ -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)
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user