Skip to content

Commit f9882cb

Browse files
committed
#40 Fixed compactMap for Swift 4.0
1 parent 3b60f74 commit f9882cb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sources/SwiftRichString/Extensions/UIKit+Extras.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,14 @@ extension UITextView {
163163
}
164164

165165
#endif
166+
167+
//MARK: - compactMap for Swift 4.0 (not necessary > 4.0)
168+
169+
#if swift(>=4.1)
170+
#else
171+
extension Collection {
172+
func compactMap<ElementOfResult>(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] {
173+
return try flatMap(transform)
174+
}
175+
}
176+
#endif

0 commit comments

Comments
 (0)