2 ms·
I agree, and the difference is easy to illustrate. quack() in duck typing, has to have no arguments and return a string (let's say). We can have a NotarizedDu
by samatman 7y ago
I agree, and the difference is easy to illustrate.
quack() in duck typing, has to have no arguments and return a string (let's say). We can have a NotarizedDuck class where quack(true) instead returns the number of times the NotarizedDuck has quacked, so long as quack() itself returns a string, it will pass the unit test.
In structural typing, it's illegal to call that quack, because it's the wrong function signature.