Skip to content
Giorgio Garofalo edited this page Jan 22, 2025 · 10 revisions

None is a particular kind of value, which represents nothing or emptiness (similarly to null in many programming languages).
This value could be returned by functions (instantiated via .none), although primarily used as a placeholder value for optional parameters.

Operations

Function Description Return type
.isnone {value} Checks whether value is none. Boolean
.otherwise {value} {fallback} Returns value if it is not none, fallback otherwise.
Works best with function call chaining.
type of either value or fallback
.takeif {value} {lambda} Returns value if the boolean-returning lambda is accepted on value. Returns none otherwise.
Works best with function call chaining.
type of value, or none

Examples

Hi! I'm .name::otherwise {unnamed}

If name is John: Hi! I'm John
If it is none: Hi! I'm unnamed

 

.num::takeif {@lambda x: .x::equals {5}}

If num is 5: 5
Otherwise: None

Confused about @lambda? It begins a parametric inline Lambda. Check its page for further details.

 

.num::takeif {@lambda x: .x::iseven}::ifpresent {Even}::otherwise {Odd}

If num is even: Even
Otherwise: Odd

 

.x::ifpresent {@lambda Yes, .1 is present}::otherwise {Not present}

If x is something: Yes, something is present
If it is none: Not present

Here, the lambda parameter is implicit and accessed by position.

Clone this wiki locally