Created
December 4, 2017 08:39
-
-
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.
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
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