Skip to content

Latest commit

 

History

History
30 lines (14 loc) · 363 Bytes

File metadata and controls

30 lines (14 loc) · 363 Bytes

Merge two dictionary

import Foundation

extension Dictionary {

    mutating func merge(with dictionary: Dictionary) {

      dictionary.forEach { updateValue( $1, forKey: $0) }

    }
    
    func merged(with dictionary: Dictionary) -> Dictionary {

        var dict = self

        dict.merge(with: dictionary)

        return dict

    }

}