Duck typing, must it be dynamic?

后端 未结 8 1124
花落未央
花落未央 2020-12-13 09:55

Wikipedia used to say* about duck-typing:

In computer programming with object-oriented programming languages, duck typing is a style of dynamic

8条回答
  •  一整个雨季
    2020-12-13 10:18

    It's my understanding that structural typing is used by type inferencers and the like to determine type information (think Haskell or OCaml), while duck typing doesn't care about "types" per se, just that the thing can handle a specific method invocation/property access, etc. (think respond_to? in Ruby or capability checking in Javascript).

提交回复
热议问题