My go-to Swift snippet over the last week. Super useful to pull dictionaries out of flat JSON structs, by passing in an array of keys and values as tuples:

let dict = Dictionary.init(uniqueKeysWithValues: someStruct.map { 
	($0.propertyOneAsKey, $0.propertyTwoAsValue) 

A close second: the mapValues method on dictionaries in all sorts of contexts, including removing keys with nil values. compactMapValues will be introduced in Swift 5, but in the meantime this is readable:

let cleaned = filter { $0.value != nil }.mapValues { $0! }
Zoë Smith @zoe