Transforming an Optional Value
An optional mapping applies an operation only when a value is present and carries absence through the result.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Trace three settings
If a stored score is absent, a rescaling step can return absence. Scores zero and seven remain present and become zero and fourteen under doubling. An absent value marker keeps legitimate zero distinct.
Distinguish absence from a new error
The operation can still fail while transforming a present value. Its contract should distinguish that error from an input with no value. See structured errors and exceptions.[1]