This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Dictionary { | |
mutating public func setValue(value: Any, forKeyPath keyPath: String) { | |
var keys = keyPath.components(separatedBy: ".") | |
guard let first = keys.first as? Key else { print("Unable to use string as key on type: \(Key.self)"); return } | |
keys.remove(at: 0) | |
if keys.isEmpty, let settable = value as? Value { | |
self[first] = settable | |
} else { |