]> Cypherpunks repositories - gostls13.git/commitdiff
spec: fix Swap example (correctly swap type arguments and parameters)
authorRobert Griesemer <gri@golang.org>
Mon, 22 Nov 2021 19:43:46 +0000 (11:43 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 22 Nov 2021 23:00:32 +0000 (23:00 +0000)
Thanks to @danscales for noticing the mistake.

Change-Id: I547ee80a78419765b82d39d7b34dc8d3bf962c35
Reviewed-on: https://go-review.googlesource.com/c/go/+/366215
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
doc/go_spec.html

index bf589f0ae660e89ecf81d025e7a4e5d59edf7b9b..ecd2f084c946ff6c533126c65a453e43d9537d8f 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification - Go 1.18 Draft (incomplete)",
-       "Subtitle": "Version of Nov 19, 2021",
+       "Subtitle": "Version of Nov 22, 2021",
        "Path": "/ref/spec"
 }-->
 
@@ -2808,7 +2808,7 @@ type Pair[A, B any] struct {
        b B
 }
 
-func (p Pair[A, B]) Swap() Pair[A, B]  { return Pair[A, B]{p.b, p.a} }
+func (p Pair[A, B]) Swap() Pair[B, A]  { return Pair[B, A]{p.b, p.a} }
 func (p Pair[First, _]) First() First  { return p.a }
 </pre>