Last active
September 15, 2018 00:34
-
-
Save pvn/5193e8c234018acd78a9782d18d47798 to your computer and use it in GitHub Desktop.
Swift: Array Extension
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
/* Compare two array has the same value */ | |
// firstArray = ['A', 'B', 'C', 'A'] | |
// secondArray = ['A', 'B', 'C', 'A'] | |
// firstArray.isDuplicateOf(secondArray) | |
extension Array where Element: Comparable { | |
func isDuplicateOf(as other: [Element]) -> Bool { | |
return self.count == other.count && self.sorted() == other.sorted() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment