1
0
mirror of https://github.com/golang/go synced 2024-11-11 23:20:24 -07:00

spec: fix Swap example (correctly swap type arguments and parameters)

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>
This commit is contained in:
Robert Griesemer 2021-11-22 11:43:46 -08:00
parent 7456b94853
commit 0244343088

View 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>