aboutsummaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2019-07-31 16:36:22 -0400
committerRuss Cox <rsc@golang.org>2019-07-31 20:38:33 +0000
commit5754551255d2cc2098697440d192b1e3555c3075 (patch)
treefb9d897d3f53dd6eb22db18f36aeeef62742b3b2 /content
parentc6b959c638282ea35a2b8796a4c1d75dba40b7ed (diff)
content/why-generics: fix ReverseAndPrint
Reverse has no return value. Change-Id: I400652e98c993555c25c3c7649518e66bfc3e9e7 Reviewed-on: https://go-review.googlesource.com/c/blog/+/188380 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'content')
-rw-r--r--content/why-generics.article6
1 files changed, 4 insertions, 2 deletions
diff --git a/content/why-generics.article b/content/why-generics.article
index 682080b..b359cf1 100644
--- a/content/why-generics.article
+++ b/content/why-generics.article
@@ -375,7 +375,8 @@ a type argument, which is like any other argument except that it's a
type.
func ReverseAndPrint(s []int) {
- fmt.Println(Reverse(int)(s))
+ Reverse(int)(s)
+ fmt.Println(s)
}
That is the `(int)` seen after `Reverse` in this example.
@@ -387,7 +388,8 @@ you don't need to mention the type argument at all.
Calling a generic function just looks like calling any other function.
func ReverseAndPrint(s []int) {
- fmt.Println(Reverse(s))
+ Reverse(s)
+ fmt.Println(s)
}
In other words, although the generic `Reverse` function is slightly