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")


Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)