FullBox type

Represents presence 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

Direct children types

Absent
Represents a target configuration list item that must be absent
ExactPresence
Represents a target configuration list item in a list
PartialPresence
Undocumented
Direct subtypes: 2
Present
Represents a target configuration list item that must be present
TestMessage
Represents an informational, human readable message a successful test would present to the user.
AWS::RouteBox
Internal type. Please do not use.
AWS::IpPermBox
Internal type. Please do not use.
AWS2::CreateOnly
A Box for a property which is to be used only at creation time, not when a resource is updated

Methods

Bool(fb:FullBox) Source: stdlib.ngs:2701
Always true
dflt(fb:FullBox, x:Any) Source: stdlib.ngs:2833
Do nothing

Returns

fb

Example

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

Returns

fb

Example

Box(10).each(echo)  # Output: 10
filter(fb:FullBox, predicate:Any) Source: stdlib.ngs:2736
Conditionaly convert FullBox to EmptyBox.

Parameters

predicateTest function to be called with the value in the FullBox

Returns

Box. fb if predicate succeeds, EmptyBox if not.

Example

Box(10).filter(X>5)   # <FullBox val=10>
Box(10).filter(X>20)  # <EmptyBox>
get(fb:FullBox, dflt:Any=null) Source: stdlib.ngs:2769
Get FullBox value

Returns

Any

Example

Box(10).get()  # 10
init(b:FullBox, *args:Arr) Source: stdlib.ngs:2685
Do not use directly! Helper constructor that throws InvalidArgument when FullBox is created with zero or more than one argument.
init(b:FullBox, val:Any) Source: stdlib.ngs:2698
FullBox constructor. Saves val into .val

Example

# Simplified code from the_one() method:
ret = EmptyBox()
something.each(F(elt) {
	if predicate(elt) {
		ret throws ElementNotFound("the_one() had more than one match")
		ret = FullBox(elt)
	}
})
not(ret) throws ElementNotFound("the_one() had no matches")
ret.val # Has the value
map(fb:FullBox, mapper:Fun) Source: stdlib.ngs:2713
Map FullBox value

Parameters

mappermapper to be called with the FullBox value

Returns

FullBox with value returned by mapper

Example

Box(10).map(X*2)  # <FullBox val=20>