Intended specifically for cases like these, the comparable
constraint
is predeclared in Go. It allows any type whose values may be used as an
operand of the comparison operators ==
and !=
. Go requires that map
keys be comparable. So declaring K
as comparable
is necessary so you
can use K
as the key in the map variable.
If you want to change selection, open document below and click on "Move attachment"
Tutorial: Getting started with generics - The Go Programming Languagee brackets), K and V, and one argument that uses the type parameters, m of type map[K]V. The function returns a value of type V. Specify for the K type parameter the type constraint comparable. <span>Intended specifically for cases like these, the comparable constraint is predeclared in Go. It allows any type whose values may be used as an operand of the comparison operators == and !=. Go requires that map keys be comparable. So declaring K as comparable is necessary so you can use K as the key in the map variable. It also ensures that calling code uses an allowable type for map keys. Specify for the V type parameter a constraint that is a union of two types: int64 and float64. Using | specifies a Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details