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
import Foundation | |
extension Sequence { | |
// Extension on Sequence allows us to use this method on Arrays, Maps, Sets, etc. | |
func uniqueElements<Index: Hashable>(for indexer: (Element) -> Index) -> [Element] { | |
// Keep track of what we've already seen in a Set, | |
// which allows us to query for elements efficiently. | |
var seenElements: Set<Index> = [] | |
var result: [Element] = [] |
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
// Extensions to simplify usage of accessibilityTraits in Swift 4.2: | |
public func |= (traits: inout UIAccessibilityTraits, other: [UIAccessibilityTraits]) { | |
for o in other { | |
traits |= o | |
} | |
} | |
public func |= (traits: inout UIAccessibilityTraits, other: UIAccessibilityTraits) { | |
// From: https://swift.org/migration-guide-swift4.2/#known-migration-issues |
OlderNewer