If you want to check whether an arbitrary object is a dictionary, first of all, you must make the object undefined:
let dict : Any = ["name":"John", "surname":"Doe"]
Now you can check if the object is a dictionary
if dict is Dictionary<AnyHashable,Any> {
print("Yes, it a Dictionary")
}
But this path is theoretical and for educational purposes only. Basically, it's pretty dumb to distinguish a non-standard type.
source
share