Optional

Adjective · Noun · Development

Definitions

  1. A wrapper type or annotation indicating that a value may be absent. In Java it is java.util.Optional; in Python, typing.Optional[T] is shorthand for Union[T, None]. Signals to callers that they must account for missing data.

    In plain English: A label on a value that says 'this might not be here,' so your code knows to check before using it.

    Example: "The function returns Optional[User] — if the ID does not match anyone, you get None instead of an exception."

Related Terms