1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-11 09:28:38 +00:00
MTMR/MTMR/GeneralExtensions.swift
Serg 475b66c956 Merge branch 'master' into musicWidget and fix hidden property usage
# Conflicts:
#	MTMR/CustomButtonTouchBarItem.swift
#	MTMR/TouchBarController.swift
2018-05-12 21:47:13 +07:00

20 lines
400 B
Swift

import Foundation
#if swift(>=4.1)
// compactMap supported
#else
extension Sequence {
func compactMap<ElementOfResult>(_ transform: (Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] {
return try flatMap(transform)
}
}
#endif
extension String {
var ifNotEmpty: String? {
return self.count > 0 ? self : nil
}
}