How to use AnyHashable in Swift
Issue #453
From documentation
A type-erased hashable value.
DiscussionThe AnyHashable type forwards equality comparisons and hashing operations to an underlying hashable value, hiding its specific underlying type.You can store mixed-type keys in dictionaries and other collections that require Hashable conformance by wrapping mixed-type keys in AnyHashable instances
1 | let descriptions: [AnyHashable: Any] = [ |
We don’t necessarily need to map from [AnyHashable: Any]
to [String: Any]
, we can just access via string key
1 | userInfo["aps"] |