pmaurais
pmaurais

Reputation: 924

Optional vs Duck Typing

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

Upvotes: 0

Views: 248

Answers (1)

Brian
Brian

Reputation: 1604

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.

Upvotes: 1

Related Questions