Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save frakingFrank/56153f2e56c632a62557a42f47ba87b7 to your computer and use it in GitHub Desktop.
Save frakingFrank/56153f2e56c632a62557a42f47ba87b7 to your computer and use it in GitHub Desktop.
Swift Apprentice by Ray Wenderlich Chapter 9 A function that returns true if all of the values of a dictionary[String:Int] are unique.
var dict = ["Eins" : 1, "Zwei": 2]
func isInvertible(_ dictionary: [String: Int]) -> Bool {
var isItTrue = true
var array : [Int] = []
for numbers in dict.values {
if array.contains(numbers) == false {
array.append(numbers)
}else{
isItTrue = false
}
}
return isItTrue
}
isInvertible(dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment