Diff type
Direct children types
- ArrDiff
Represents difference of elements between two arrays (order unimportant)
- HashDiff
Represents difference of elements between two hashes (order unimportant)
Constructors
- 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, eq:Fun)experimental Source: stdlib.ngs:3039
EXPERIMENTAL! Do not use! Compare arrays using eq as equality test. 2*n*m comparisons Returns
ArrDiff
- 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
- Diff(a:Hash, b:Hash) Source: stdlib.ngs:3106
Compare hashes Example
diff = Diff(current_tags, target_tags) if (tags = AWS::cli_tags(diff.add + diff.change)) { r.run('update_tags/add', %(aws ec2 create-tags --resources ${r.id()} --tags $*tags)) } if (tags = diff.remove / "Key=$X") { r.run('update_tags/remove', %(aws ec2 delete-tags --resources ${r.id()} --tags $*tags)) }