Skip to content

Null

Bases: OptionType[T]


              flowchart TD
              pyochain.rs.Null[Null]
              pyochain.rs.OptionType[OptionType]
              pyochain.rs.Pipe[Pipe]

                              pyochain.rs.OptionType --> pyochain.rs.Null
                                pyochain.rs.Pipe --> pyochain.rs.OptionType
                



              click pyochain.rs.Null href "" "pyochain.rs.Null"
              click pyochain.rs.OptionType href "" "pyochain.rs.OptionType"
              click pyochain.rs.Pipe href "" "pyochain.rs.Pipe"
            

Option variant representing the absence of a value.

This class or NONE can be used interchangeably, as calling Null() will always return the singleton instance NONE.

For pattern matching, you must use Null, as NONE isn't special cased by type checkers the same way python None is, and thus can't be narrowed to Null.

For more documentation, see the Option[T] class.

Example
>>> from pyochain import Null, NONE, Some, Option
>>> Null() is NONE
True
>>> def is_none(x: Option[int]) -> bool:
...     match x:
...         case Null():
...             return True
...         case Some(_):
...             return False
>>> is_none(NONE)
True
>>> is_none(Some(42))
False
>>> is_none(Null())
True