[generics] Typo in draft

64 views
Skip to first unread message

Diego Augusto Molina

unread,
Jun 28, 2020, 4:45:34 PM6/28/20
to golan...@googlegroups.com
Hi, I think I spotted a small typo in the draft. In Examples >
Containers we have:
<code>
// Find returns the value associated with a key, or zero if not present.
// The bool result reports whether the key was found.
func (m *Map(K, V)) Find(k K) (V, bool) {
pn := m.find(k)
if *pn == nil {
var zero val // see the discussion of zero values, above
return zero, false
}
return (*pn).v, true
}
</code>

Whereas I think it should be:
<code>
// Find returns the value associated with a key, or zero if not present.
// The bool result reports whether the key was found.
func (m *Map(K, V)) Find(k K) (V, bool) {
pn := m.find(k)
if *pn == nil {
var zero V // see the discussion of zero values, above
return zero, false
}
return (*pn).v, true
}
</code>

Patch attached.
fix-typo.patch

Ian Lance Taylor

unread,
Jun 28, 2020, 6:18:16 PM6/28/20
to Diego Augusto Molina, golang-nuts
Thanks, sent https://golang.org/cl/240340.

Ian
Reply all
Reply to author
Forward
0 new messages