-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11.07.2012 21:53,
amiw...@gmail.com wrote:
> Hay Guys!
>
> I am looking for information about the polymorphism in GO. Can
> anyone help me find an informative topics? Explanations are great
> too!
According to [1]:
Ad-hoc polymorphism: Supported with interfaces. You call a method with
the same name on any number of objects that implement a particular
interface, and they will behave differently, depending on the
implementation.
Parametric polymorphism: No generics. But if you write a function that
works with interfaces (well, object implementing interfaces), not
types, then you can have parametric polymorphism as well (a single
function implementation that works correctly, and with the same
algorithm, on any type that implements the right interface correctly).
Subtype polymorphism: Not applicable (Go doesn't have subtyping).
Although if you embed a struct A implementing interface X into a
struct B, struct B will implement interface X, and can be used instead
of struct A in places where struct A is expected. So, kind of yes.
[1]
http://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla -
http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJP/doMAAoJEOs4Jb6SI2Cw+qcH/3kruQ/BKmiMf3oGaOMGkGTQ
Lzqs2JKhlI8vP9ImNExslRuV3K7mgZof1eRci1U9qigDoWNNaVm7o3r4RzOKjYNo
LOZWQVGmTFXxgj1j7xOfoHGPDm/ZkODph6yJoV2zRimm5PbFzi3GLcmBaKP76kW3
HsY9QE7XUSOgxmhStE+myF3nfbmcyaY8oodswl/Hu3tSano02/0LXgutzYFIBjc7
aJdsUtGcHtXxluddFIwXCRdqg89E5O9X82b3hnwptFtAMucDWBmQj/8s9kLEcBLH
Yt8ZgLt89ZEl5cdaZOBkIyYLKN9OtX5mIZyb12S19ldcATYXB4Eu6peeY7gQ21w=
=mveg
-----END PGP SIGNATURE-----