3 ms·
Except Typescript embraces duck typing. You can say "accept any object with a quack() method", for example, and it'll accept an unexpected quacking parrot. It
by Izkata 1y ago
Except Typescript embraces duck typing. You can say "accept any object with a quack() method", for example, and it'll accept an unexpected quacking parrot. It can even tell when two type definitions are close enough and merge them.
- pjmlp 1y agoKind of, depends on the compiler configuration.
- shepherdjerred 1y agoDoesn't Go also use structural typing?
- jmholla 1y agoSo does Python. They're called protocols. [0] [0]: https://typing.python.org/en/latest/spec/protocol.html https://typing.python.org/en/latest/spec/protocol.html
- dragonwriter 1y ago> Except Typescript embraces duck typing. So does Python: https://typing.python.org/en/latest/spec/protocol.html https://typing.python.org/en/latest/spec/protocol.html
- zephyrfalcon 1y agoIt's not duck typing if you have to declare the type...