Reading from the github docs I can see how to use it, but when I try to initialize it (to empty):
var responses: OrderedDictionary = [:]
it says: Empty collection literal requires an explicit type
I tried this:
var responses: OrderedDictionary<String: <TransactionsDataItemsClassAModel>> = [:]
but doesn't work, what's the proper way to initialize this?
This is how I have initialized my non ordered diccionary:
var dataDiccionary: [String: [TransactionsDataItemsClassAModel]] = [:]
Thanks
CodePudding user response:
The regular syntax for generic types is like Array<T>
and Dictionary<K, V>
- There's short-hand syntax specific to
Array
andDictionary
:[T]
and[K: V]
.
You're confusing some things and combined the two into an an invalid middle-ground.
OrderedDictionary
doesn't have any special short-hands, so you would just treat it like any other generic type. The generic type parameters are specified with a comma separated list:
OrderedDictionary<String, [TransactionsDataItemsClassAModel]>