extension Optional { func try<U>(f: (T) -> U) -> Optional<U> { if let unwrapped = self { return f(unwrapped) } else { return nil } } }
https://gist.github.com/nottombrown/c6585cad9588a9dc5383
https://gist.github.com/nottombrown/c6585cad9588a9dc5383