Box type
Direct parent types
- Eachable1
Eachable which each() calls the callback with one argument Direct subtypes: 16
Direct children types
- EmptyBox
Represents absence of a value
- FullBox
Represents presence of a value Direct subtypes: 8
Constructors
- Box(x:Any) Source: stdlib.ngs:3819
Convert anything to Box (always FullBox) Parameters
x value to enclose in a box Returns
FullBox with given valueExample
Box(7).map(X*2).get() # 14
- Box() Source: stdlib.ngs:3826
Convert Box with no arg to EmptyBox Returns
EmptyBoxExample
Box() == EmptyBox() Box().get(10) # 10 Box().map(X*2).get() # InvalidArgument exception (in "get()")
- Box(n:Null) Source: stdlib.ngs:3835
Convert null to Box (always EmptyBox) Returns
EmptyBoxExample
Box(null) == EmptyBox() Box(null).map(X*2).get() # InvalidArgument exception (in "get()")
- Box(a:Arr, idx:Int) Source: stdlib.ngs:3847
Convert array value indexed by the given index Parameters
idx key to look in hash Returns
Box. FullBox if the array has the element indexed by idx, EmptyBox otherwise.Example
my_array = [10, 20] my_array.Box(1).map(X*2).each(echo) # output: 40 my_array.Box(5).map(X*2).each(echo) # no output
- Box(h:Hash, k:Any) Source: stdlib.ngs:3858
Convert hash value indexed by the given key to a Box Parameters
k key to look in hash Returns
Box. FullBox if the hash has the element referenced by k, EmptyBox otherwise.Example
my_hash = {"a": 10, "b": 300} my_hash.Box("a").map(X*2).each(echo) # output: 20 my_hash.Box("nope").map(X*2).each(echo) # no output
- Box(s:Success) Source: stdlib.ngs:6881
Convert Success to FullBox Returns
FullBoxExample
Box("abcd" ~ /^(..)/).map({"First two letters: ${A[1]}"}).get("(too short)") # First two letters: ab
- Box(f:Failure) Source: stdlib.ngs:6886
Convert failure to EmptyBox Returns
EmptyBoxExample
Box("a" ~ /^(..)/).map({"First two letters: ${A[1]}"}).get("(too short)") # (too short)
Methods
- ==(b1:Box, b2:Box) Source: stdlib.ngs:3894
Compare boxes. Empty boxes and boxes with same content are considered to be equal. Returns
BoolExample
EmptyBox() == EmptyBox() EmptyBox() != FullBox(1) FullBox(1) == FullBox(1) FullBox(1) != FullBox(2)
- del(t:TmpFsObj, kcp:KeepCleanupPolicy, e:Box) Source: stdlib.ngs:5451
Undocumented
- del(t:TmpFsObj, rcp:RemoveCleanupPolicy, e:Box) Source: stdlib.ngs:5456
Undocumented
- del(t:TmpFsObj, koecp:KeepOnErrorCleanupPolicy, e:Box) Source: stdlib.ngs:5466
Undocumented
- ExitCode(b:Box) Source: stdlib.ngs:3741
Zero for FullBox and one for EmptyBox