Created
June 24, 2017 01:25
-
-
Save hiroshi-maybe/04357eb71d4f79dfb353c15a019a5d12 to your computer and use it in GitHub Desktop.
This file contains 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
protocol OptionalType { | |
associatedtype W | |
var optional: W? { get } | |
} | |
extension Optional: OptionalType { | |
typealias W = Wrapped | |
var optional: W? { return self } | |
} | |
extension Array where Element: OptionalType { | |
func unwrap() -> [Element.W] { | |
return flatMap { $0.optional } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment