Tech Tip: How to compare two objects
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: January 10, 2022
To compare two objects, convert each object into a collection using the command New collection, and then use the collection.equal() method to compare the collections. For example:
$objectA:=New object("Name"; "Frank"; "Age"; 29; "Job"; "Physician") $objectB:=New object("Name"; "Frank"; "Job"; "Physician"; "Age"; 29) $objectC:=New object("Name"; "FRANK"; "Age"; 29; "Job"; "Physician") $equal1:=New collection($objectA).equal(New collection($objectB); ck diacritical) // True $equal2:=New collection($objectA).equal(New collection($objectC); ck diacritical) // False |
Note that the ck diacritical constant is passed in the 2nd parameter to strictly evaluate case-sensitivity and accented characters.