Reputation: 433
I am trying to find the proper syntax to initialize "Map<,<List<List>>>" in kotlin. I am a bit new to kotlin. I have variables initialized in my class as this:
var jitterMs: Double = 0.0
The way I am trying to initialize is this:
val bandMap: Map<Int,<List<List<String>>>> = emptyMap()
It gives me an error that a proper getter or setter is expected, and I think that's because it just doesn't understand what I am trying to do. What is wrong with this syntax?
Thanks,
Edit: As Tenfour pointed out, I actually want a mutable map. This is what I have now as an error saying there is a type error:
val bandMap: MutableMap<Int,List<List<String>>> = emptyMap()
Upvotes: 0
Views: 619
Reputation: 991
This is how you would do it:
val bandMap: Map<Int, List<List<String>>> = emptyMap()
For a MutableMap
write the following:
val bandMap: MutableMap<Int, List<List<String>>> = mutableMapOf()
Or, for the most idiomatic way to make a mutableMap
would be:
val bandMap = mutableMapOf<Int, List<List<String>>>()
Upvotes: 2
Reputation: 2732
val bandMap: Map<Int,List<List<String>>> = emptyMap()
This will work. You added extra < >
Upvotes: 0