flavored¶
Sentinel values labeled by different (hashable) flavors.
When different flavors of the truth are needed.
Note
Can be compared using == and !=. A flavored sentinel
value always equals itself and never equals anything else,
especially other flavored sentinel values.
Useful for union types where Sentinel[H] is one of the
types making up the union.
To ensure that reference equality is used, put the known sentinel value first in the comparison.
Note
Threadsafe.
- final class pythonic_fp.gadgets.sentinels.flavored.Sentinel(flavor: H)¶
- Parameters:
flavor – Some Hashable value of generic type
H.- Returns:
The
Sentinelsingleton instance with flavorflavor.- Return type:
Sentinel[H]whereHis a subtype of Hashable.
- flavor() H¶
- Returns:
The sentinel’s flavor. A
Hashablevalue of typeH.