It's because AnyHashable is not an existential like Any but a value type (I believe it was a struct) which erases the type restriction from your Hashable type. Simply look up AnyHashable.
-- Adrian Zubarev Sent with Airmail Am 23. März 2017 um 12:07:16, Седых Александр via swift-users (swift-users@swift.org(mailto:swift-users@swift.org)) schrieb: > > Hello again :) > > I have another question. > > Why Type casting for Keys of Dictionaries don't work > > > enum Key { > > > case one > > > } > > > > > > let dict: [AnyHashable: Any] = [Key.one : "Hello"] > > > let unwrap: [Key: Any] = dict as! [Key : Any] // error > > > > > -- > Седых Александр _______________________________________________ > swift-users mailing list > swift-users@swift.org > https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users