Bool type
Constructors
- Bool(x:Any)
Convert to Bool. Str, Arr and Hash of non-zero size return true. Bool returns as is. Null returns false. Int returns true if it is not zero. Parameters
x Bool or Int or Str or Arr or Hash or Null Returns
Bool
- Bool(udm:UserDefinedMethod) Source: stdlib.ngs:398
Undocumented Returns
true
- Bool(mm:MultiMethod) Source: stdlib.ngs:410
Whether MultiMethod has any methods
- Bool() Source: stdlib.ngs:464
Make false Returns
false
- Bool(s:Success) Source: stdlib.ngs:958
Convert Success to Bool (true) Returns
true
- Bool(f:Failure) Source: stdlib.ngs:962
Convert Failure to Bool (false) Returns
false
- Bool(ms:MatchSuccess) Source: stdlib.ngs:999
Undocumented Returns
true
- Bool(mf:MatchFailure) Source: stdlib.ngs:1005
Undocumented Returns
false
- Bool(al:ArrLike) Source: stdlib.ngs:1911
Check whether al has any elements.
- Bool(a:AnyOf) Source: stdlib.ngs:1979
Checks whether any of the items are truthy.
- Bool(a:AllOf) Source: stdlib.ngs:2007
Checks whether all items are truthy.
- Bool(hl:HashLike) Source: stdlib.ngs:2073
Check whether hl has any elements. Returns
Bool
- Bool(s:Set) Source: stdlib.ngs:2208
Check whether the set is not empty
- Bool(r:Real) Source: stdlib.ngs:2392
Undocumented
- Bool(fb:FullBox) Source: stdlib.ngs:4218
Always true
- Bool(eb:EmptyBox) Source: stdlib.ngs:4221
Always false
- Bool(d:ArrDiff) Source: stdlib.ngs:4575
Check whether there is a difference Returns
BoolExample
arr_diff = Diff(current, desired) # Implicit Bool() when using in "if": if arr_diff -> if Bool(arr_diff) if arr_diff { echo("Will make modifications to the resource") if arr_diff.add { ... } if arr_diff.remove { ... } }
- Bool(d:HashDiff) Source: stdlib.ngs:4611
Whether there is a difference Returns
BoolExample
hash_diff = Diff(current_properties, desired_properties) # Implicit Bool() when using in "if": if hash_diff -> if Bool(hash_diff) if hash_diff { echo("Will make modifications to the resource") if hash_diff.add { ... } if hash_diff.remove { ... } if hash_diff.change { ... } }
- Bool(p:Path) Source: stdlib.ngs:5668
Checks whether the path is accessible using access(2) and F_OK. Returns
Bool
- Bool(p:Path)experimental Source: stdlib.ngs:5681
Check whether file system object at given path is of the given type. Example
if File("myfile.txt") ... if Dir("my_tmp_dir") ...
- Bool(p:Program) Source: stdlib.ngs:5953
Checks whether the given program is found in path. Returns
Bool. The program is found in path or program name is absolute
- Bool(pp:ProcessesPipeline) Source: stdlib.ngs:6478
Wait for all process to finish and see whether all exit codes are 0 Returns
BoolExample
if $(test -f myfile) ... # if runs Bool() on any non-Bool condition expression
- Bool(t:Time) Source: stdlib.ngs:8267
Undocumented
- Bool(rd:ResDef)
Check whether any resources were found. Returns
BoolExample
# Implicit Bool(): if expr -> if Bool(expr) if AWS::Instance({"env": "dev", "role": "edge"}) { echo("There is at least one edge server in dev environment") }
- Bool(i:MapIter)
EXPERIMENTAL! Do not use!
- Bool(i:FilterIter)
EXPERIMENTAL! Do not use!
- Bool(i:FunIter)
EXPERIMENTAL! Do not use!
- Bool(i:ConstIter)
Convert ConstIter to Bool (true). Returns
true
- Bool(i:RangeIter)
Check whether there is at least one uniterated item in range. Returns
Bool. true: next() will return next element. false: next() will throw NoNext
- Bool(i:ArrIter)
Check whether there are more array elements to iterate over. Returns
Bool. true: next() will return next element. false: next() will throw NoNext
- Bool(i:HashIter)
Check whether there are more pairs to iterate over. Returns
Bool. true: next() will return next pair. false: next() will throw NoNext
- Bool(t:Table)
Check whether there are any rows in the table.
- Bool(d:Description)
Undocumented
- Bool(t:Terminal)
Undocumented
Methods
- ==(a:Bool, b:Bool)
Compare booleans
- code(b:Bool) Source: stdlib.ngs:4621
Convert a Bool to NGS code that would produce the given Bool when executed. Not fully functional yet. Returns
Str
- Diff(a:Arr, b:Arr, full:Bool=false) Source: stdlib.ngs:4499
Compare arrays. Warning: by default Hash is used so internal Hash keys comparison is used, not == Parameters
full Do not use Hash, work slower but use == comparison. Example
Diff([1,2], [2,3]) # .add = [3] .remove = [1]
- Diff(a:Arr, b:Arr, full:Bool=false) Source: stdlib.ngs:4535
Compare arrays. Warning: by default Hash is used so internal Hash keys comparison is used, not == Parameters
b Arr[PartialPresence] full Do not use Hash, work slower but use == comparison. Returns
ArrDiffExample
Diff([1,2,3], [Present(1)]) # <ArrDiff add=[] remove=[]> Diff([1,2,3], [Present(5)]) # <ArrDiff add=[5] remove=[]> Diff([1,2,3], [Absent(1)]) # <ArrDiff add=[] remove=[1]> Diff([1,2,3], [Absent(5)]) # <ArrDiff add=[] remove=[]> Diff(["a", "b"], [Present("a"), Present("c"), Absent("b"), Absent("d")]) # <ArrDiff add=[c] remove=[b]>
- Diff(a:Arr, b:Arr, full:Bool=false) Source: stdlib.ngs:4558
Compare arrays. Warning: by default Hash is used so internal Hash keys comparison is used, not ==. Calls Diff(a, b.map(get), full) Parameters
b Arr[ExactPresence] full Do not use Hash, work slower but use == comparison. Returns
Diff
- ExitCode(b:Bool) Source: stdlib.ngs:157
Undocumented Returns
0 for true, 1 for false
- finished_ok(p:Process, field_name:Str, ok:Bool)internal Source: stdlib.ngs:6397
Decide whether a process finished normally. Example
# 'ok' option is set to true when the value is missing after ':' $(ok: ls no-such-file)
- Int(b:Bool) Source: stdlib.ngs:4692
Convert Bool to int. Returns
IntExample
true.Int() # 1 false.Int() # 0
- JsonData(b:Bool) Source: stdlib.ngs:4624
Convert Bool into JSON compatible data structure - boolean
- not(x:Bool)
Invert boolean
- report(tr:TestsResults, group_name:Str, test_name:Str, result:Result, critical:Bool)
Undocumented
- Str(b:Bool) Source: stdlib.ngs:4736
Undocumented
- Str(t:Time, format:Str='%F %T %Z', gmt:Bool=false) Source: stdlib.ngs:8253
String representation of Time Parameters
format strftime(3) format gmt Use GMT time zone (defaults to local time zone)
- test(results:TestsResults, group:Str, name:Str, f:Fun, critical:Bool=true)
EXPERIMENTAL! Do not use! Runs f as a test in a test group
- ~~(haystack:Str, needle:Str, collect_unmatched:Bool=false) Source: stdlib.ngs:5082
Find all non-overlapping matches of a substring in a string. Returns
if collect_unmatched - Arr with each element being MatchSuccess or Str, if not collect_unmatched - Arr of MatchSuccess
- ~~(s:Str, r:RegExp, collect_unmatched:Bool=false) Source: stdlib.ngs:7670
Find all non-overlapping matches of regular expression in a string. Returns
if collect_unmatched - Arr with each element being MatchSuccess or Str, if not collect_unmatched - Arr of MatchSuccessExample
("x10ab20c30y" ~~ /[0-9]+/).whole.map(Int).sum() # 60 arr = (~~)("x10ab20c30y", /[0-9]+/, true) arr .= map(F(elt) if elt is MatchSuccess "[${elt.whole}]" else elt) arr.join("") # "x[10]ab[20]c[30]y"