EmptyBox type

Represents absence of a value

Direct parent types

Box
A box which might (FullBox) or might not (EmptyBox) contain a value. Box is somewhat similar to Arr of zero (EmptyBox) or exactly one (FullBox) element. This analogy helps understanding each() and filter() operation.
Direct subtypes: 2
NoData
Absence of data
Direct subtypes: 2

Methods

Bool(eb:EmptyBox) Source: stdlib.ngs:2704
Always false
dflt(eb:EmptyBox, x:Any) Source: stdlib.ngs:2844
Wrap x in a Box

Returns

FullBox with the value x

Example

my_array = [10, 20]
# dflt on FullBox has no effect
my_array.Box(1).dflt(100).map(X*2).each(echo)
# output: 40
# dflt on EmptyBox creates FullBox with the given value
my_array.Box(5).dflt(100).map(X*2).each(echo) # HERE
# output: 200
each(eb:EmptyBox, cb:Fun) Source: stdlib.ngs:2728
Do nothing

Returns

eb

Example

Box(null).each(echo)  # No output
filter(eb:EmptyBox, predicate:Any) Source: stdlib.ngs:2744
Do nothing

Returns

eb

Example

EmptyBox().filter(X>20)  # <EmptyBox>
get(eb:EmptyBox) Source: stdlib.ngs:2772
Get EmptyBox value. Always throws BoxFail.
get(eb:EmptyBox, dflt:Any) Source: stdlib.ngs:2778
Get EmptyBox value

Returns

dflt
map(eb:EmptyBox, mapper:Fun) Source: stdlib.ngs:2718
Do nothing

Returns

eb

Example

EmptyBox().map(X*2)  # <EmptyBox>