1
0
mirror of https://github.com/golang/go synced 2024-11-21 12:54:45 -07:00

faq: go does not have duck typing

R=golang-dev, 0xjnml, iant, adonovan, aram
CC=golang-dev
https://golang.org/cl/6500092
This commit is contained in:
Rob Pike 2012-09-07 14:01:02 -07:00
parent d5ab44e2fe
commit 4be9b83eb6

View File

@ -541,7 +541,7 @@ Why doesn't Go have "implements" declarations?</h3>
<p> <p>
A Go type satisfies an interface by implementing the methods of that interface, A Go type satisfies an interface by implementing the methods of that interface,
nothing more. This property allows interfaces to be defined and used without nothing more. This property allows interfaces to be defined and used without
having to modify existing code. It enables a kind of "duck typing" that having to modify existing code. It enables a kind of structural typing that
promotes separation of concerns and improves code re-use, and makes it easier promotes separation of concerns and improves code re-use, and makes it easier
to build on patterns that emerge as the code develops. to build on patterns that emerge as the code develops.
The semantics of interfaces is one of the main reasons for Go's nimble, The semantics of interfaces is one of the main reasons for Go's nimble,