mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-21 00:47:11 +08:00
Merge pull request #47 from c0dehu1k/issue-46
[Issue#46 ]fixed typo with command quotes
This commit is contained in:
commit
77c6b74df0
1 changed files with 1 additions and 1 deletions
|
|
@ -80,7 +80,7 @@ To handle the map, we defined two kinds of type parameters. First, the values ca
|
|||
var m map[[]byte]int
|
||||
```
|
||||
|
||||
This code leads to a compilation error: `invalid map key type []byte`. Therefore, instead of accepting any key type, we are obliged to restrict type arguments so that the key type meets specific requirements. Here, being comparable (we can use `==` or `!=`). Hence, we defined `K` as `comparable` instead of `a``ny`.
|
||||
This code leads to a compilation error: `invalid map key type []byte`. Therefore, instead of accepting any key type, we are obliged to restrict type arguments so that the key type meets specific requirements. Here, being comparable (we can use `==` or `!=`). Hence, we defined `K` as `comparable` instead of `any`.
|
||||
|
||||
Restricting type arguments to match specific requirements is called a constraint. A constraint is an interface type that can contain:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue