I have a sequence of (key, value) tuples that exactly match my dictionary form. Surely I didn't need to write this extension myself. Or did I?
extension Dictionary {
public init<Sequence : SequenceType where Sequence.Generator.Element == (Key, Value) >(_ tuples: Sequence) {
self.init()
for (key, value) in tuples {
self[key] = value
}
}
}
I would be happy to know that initializing a dictionary from a tuple sequence already exists, but I was too dumb to figure out how to access it standardly.