This file contains hidden or 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
precedencegroup CompositionPrecedence { | |
associativity: left | |
} | |
infix operator >>>: CompositionPrecedence | |
func >>><T, U, V>( | |
f: @escaping (T) -> U, | |
g: @escaping (U) -> V | |
) -> (T) -> V { |
This file contains hidden or 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
func getIndexPathArrayBetween(_ startIndex: Int, and endIndex: Int, section: Int = 0) -> [IndexPath] { | |
assert(startIndex >= 0 && endIndex > startIndex, "startIndex >= 0 && endIndex > startIndex") | |
return (startIndex...endIndex).map { IndexPath(row: $0, section: section) } | |
} |
This file contains hidden or 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
import Foundation | |
extension Optional where Wrapped: Collection { | |
var isEmptyOrNil: Bool { | |
self?.isEmpty ?? true | |
} | |
var isNilOrEmpty: Bool { | |
isEmptyOrNil | |
} |
This file contains hidden or 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
let currencySymbols = [ | |
"د.إ", | |
"؋", | |
"L", | |
"֏", | |
"ƒ", | |
"Kz", | |
"$", | |
"ƒ", | |
"₼", |
This file contains hidden or 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
infix operator ???: NilCoalescingPrecedence | |
public func ??? <T>(optional: T?, defaultValue: @autoclosure () -> String) -> String { | |
return optional.map { String(describing: $0) } ?? defaultValue() | |
} |
This file contains hidden or 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
import Foundation | |
class Debouncer { | |
/** | |
Create a new Debouncer instance with the provided time interval. | |
- parameter timeInterval: The time interval of the debounce window. | |
*/ | |
init(timeInterval: TimeInterval) { |
This file contains hidden or 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
import Foundation | |
class Person { | |
let name: String | |
private var teams = [Team]() | |
public var sortedTeams: [Team] { | |
return teams.sorted(by: { $0.rank < $1.rank }) | |
} | |
This file contains hidden or 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
import UIKit | |
extension UIView { | |
func addSubviews(_ views: UIView...) { | |
views.forEach { addSubview($0) } | |
} | |
} |
This file contains hidden or 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
import UIKit | |
extension UIView { | |
var subviewsRecursive: [UIView] { | |
return subviews + subviews.flatMap { $0.subviewsRecursive } | |
} | |
} |
NewerOlder