4 ms·
Why the exception for built-in types?
by wnoise 10y ago
Why the exception for built-in types?
- perfmode 10y agoI think it might be because you can't define methods on built-in types. func (s *[]string) Foo() is not valid. func (m map[int]string) Bar() is not valid.
- wowoc 10y agoThat too, but I rather meant predeclared named types. According to Go specification, types that you define with "type Name OldName" are named, but "int", "string" and the rest are named too. Go disallows declaring methods on predeclared types. https://golang.org/ref/spec#Types https://golang.org/ref/spec#Types