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(mm:MultiMethod) Source: bootstrap.ngs:60
Whether MultiMethod has any methods
- Bool(al:ArrLike) Source: stdlib.ngs:669
Check whether al has any elements.
- Bool(hl:HashLike) Source: stdlib.ngs:735
Check whether hl has any elements. Returns
Bool
- Bool(fb:FullBox) Source: stdlib.ngs:2701
Always true
- Bool(eb:EmptyBox) Source: stdlib.ngs:2704
Always false
- Bool(s:Success) Source: stdlib.ngs:2960
Convert Success to Bool (true) Returns
true
- Bool(f:Failure) Source: stdlib.ngs:2964
Convert Failure to Bool (false) Returns
false
- Bool(d:ArrDiff) Source: stdlib.ngs:3095
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:3131
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:3990
Checks whether the path is accessible using access(2) and F_OK. Returns
Bool
- Bool(p:Path)experimental Source: stdlib.ngs:4003
Check whether file system object at given path is of the given type. Example
if File("myfile.txt") ... if Dir("my_tmp_dir") ...
- Bool(cp:CommandsPipeline) Source: stdlib.ngs:4560
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(my:MatchY) Source: stdlib.ngs:5265
Convert successful match to Bool (true) Returns
true
- Bool(my:MatchN) Source: stdlib.ngs:5269
Convert failed match to Bool (false) Returns
false
- Bool(rd:ResDef) Source: autoload/Res.ngs:107
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) Source: autoload/Iter.ngs:119
EXPERIMENTAL! Do not use!
- Bool(i:FilterIter) Source: autoload/Iter.ngs:173
EXPERIMENTAL! Do not use!
- Bool(i:FunIter) Source: autoload/Iter.ngs:220
EXPERIMENTAL! Do not use!
- Bool(i:ConstIter) Source: autoload/Iter.ngs:235
Convert ConstIter to Bool (true). Returns
true
- Bool(i:RangeIter) Source: autoload/Iter.ngs:265
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) Source: autoload/Iter.ngs:306
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) Source: autoload/Iter.ngs:347
Check whether there are more pairs to iterate over. Returns
Bool. true: next() will return next pair. false: next() will throw NoNext
- Bool(s:Set) Source: autoload/Set.ngs:39
Check whether the set is not empty
- Bool(t:Table) Source: autoload/Table.ngs:106
Check whether there are any rows in the table.
- Bool(d:Description)
Undocumented
Methods
- ==(a:Bool, b:Bool)
Compare booleans
- assert(condition:Bool, msg:Str) Source: stdlib.ngs:71
Throws AssertFail with givens message if condition is false Returns
Unspecified, do not count on this valueExample
my_array=[] # ... Code that adds elements to my_array ... assert(my_array.len() > 3, "my_array must have more than 3 elements") # AssertFail exception, with the given message
- assert(condition:Bool) Source: stdlib.ngs:78
Throws AssertFail if condition is false Returns
Unspecified, do not count on this valueExample
my_array=[] # ... Code that adds elements to my_array ... assert(my_array.len() > 3) # AssertFail exception, with "Assertion failed" message
- code(b:Bool) Source: stdlib.ngs:3137
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:3019
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:3055
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:3078
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: bootstrap.ngs:45
Undocumented Returns
0 for true, 1 for false
- init(i:FilterIter, upstream_iter:Iter, predicate:Any, invert_predicate:Bool=false) Source: autoload/Iter.ngs:129
EXPERIMENTAL! Do not use!
- inspect(b:Bool) Source: stdlib.ngs:5651
Inspect boolean. Returns
Arr with one element, Str
- Int(b:Bool) Source: stdlib.ngs:3193
Convert Bool to int. Returns
IntExample
true.Int() # 1 false.Int() # 0
- not(x:Bool)
Invert boolean
- report(tr:TestsResults, group_name:Str, test_name:Str, result:Result, critical:Bool) Source: autoload/TestsResults.ngs:14
Undocumented
- Str(b:Bool) Source: stdlib.ngs:3230
Undocumented
- Str(t:Time, format:Str='%F %T %Z', gmt:Bool=false) Source: stdlib.ngs:5867
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) Source: autoload/test.ngs:35
EXPERIMENTAL! Do not use! Runs f as a test in a test group
- ~~(haystack:Str, needle:Str, collect_unmatched:Bool=false) Source: stdlib.ngs:3527
Find all non-overlapping matches of a substring in a string. Returns
if collect_unmatched - Arr with each element being MatchY or Str, if not collect_unmatched - Arr of MatchYExample
["key=value", "key2=value2"].map(F(kv) { m = kv ~ "=" [m.before, m.after] }).Hash() # {'key': 'value', 'key2': 'value2'}
- ~~(s:Str, r:RegExp, collect_unmatched:Bool=false) Source: stdlib.ngs:5444
Find all non-overlapping matches of regular expression in a string. Returns
if collect_unmatched - Arr with each element being MatchY or Str, if not collect_unmatched - Arr of MatchYExample
("x10ab20c30y" ~~ /[0-9]+/).whole.map(Int).sum() # 60 arr = (~~)("x10ab20c30y", /[0-9]+/, true) arr .= map(F(elt) if elt is MatchY "[${elt.whole}]" else elt) arr.join("") # "x[10]ab[20]c[30]y"