ivy.default(x: Any, default_val: Any, catch_exceptions: bool = False, rev: bool = False, with_callable: bool = False) → Any[source]

Returns x provided it exists (is not None), else returns default value.

  • x (value if catch_exceptions=False else callable) – Input which may or may not exist (be None).

  • default_val (any) – The default value.

  • catch_exceptions (bool, optional) – Whether to catch exceptions from callable x. Default is False.

  • rev (bool, optional) – Whether to reverse the input x and default_val. Default is False.

  • with_callable (bool, optional) – Whether either of the arguments might be callable functions. Default is False.


x if x exists (is not None), else default.

Supported Frameworks:

empty jax_logo empty tf_logo empty pytorch_logo empty mxnet_logo empty numpy_logo empty