Check if 2 dictionaries are equal


I have two dictionaries and want to check if they are equal (if it's the same dictionary, with the exact same key-value pairs).


// Initialize the Dictionaries
let d1 = ["name": "John", "surname": "Doe"]
let d2 = ["name": "Jane", "surname": "Doe"]
// Check if they are the same

if d1==d2 {
    print("D1 is the same as D2")
else {
    print("D1 is not the same as D2")



Find answers here

Hi there! Ask Us a Question We are ready to help