Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //: Playground - noun: a place where people can play
- import Cocoa
- extension Array {
- func dictionary<K: Hashable, V>() -> [K: V] where Element == Dictionary<K, V>.Element {
- var dictionary = [K: V]()
- for element in self {
- dictionary[element.key] = element.value
- }
- return dictionary
- }
- }
- var dictionary = ["x": 7, "y": 3, "n": 14, "z": 9]
- dictionary = dictionary.filter{ $0.value % 7 == 0 }.dictionary()
- dictionary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement