Member-only story
Compare Dictionaries with a Value of Any type (Swift)
Comparing a Type of Any? No problem!
3 min readApr 15, 2020
Difficulty: Beginner | Easy | Normal | Challenging
Whilst going through Apple’s guide “Storing Keys in the Keychain” I noticed one thing.
The queries are of type [String: Any] , so I want to test the creation of the query.
I’ll need to test the keys and values of type String and Any are created correctly, respectively.
I’ll need to compare Any value types. :(
Prerequisites:
- Be able to produce a “Hello, World!” iOS application (guide HERE)
- Knowledge of Swift’s Equatable protocol (guide HERE)
- Knowledge of Swift’s Hashable protocol (guide HERE)
Some knowledge of:
- Value and reference types (guide HERE)
Terminology
Any: An instance of any type, including function types
Dictionary: The association between keys and values (where all the keys are of the same type, and all values are of the same type)
Equatable: A protocol that can be applied to a type to allow value equality