0

What is difference between Optional Typing in Groovy and Duck Typing in Python?

pmaurais
  • 734
  • 2
  • 9
  • 30

1 Answers1

1

Optional typing refers to the Optional import from from typing import Optional. It allows you to specify types that must be upheld or be None (see: How should I use the Optional type hint?). Duck typing refers to a practice in python of "it it quacks like a duck and walks like a duck, then it's a duck". In other words, if you have something that is iterable, has a length, etc... then while it might not exactly be a list, you can treat it like a list. see this link.

Brian
  • 1,572
  • 9
  • 18