How can I make a mutable list of mutable maps?

Viewed 119

My attempt:

val areas = mutableListOf<mutableMapOf<Double, Double>()>()

On mutableListOf it shows an error Function invocation 'mutableListOf(...)' expected

1 Answers

mutableMapOf<Double, Double>() is a function call that creates a map. You need to first create a list and only specify the type of its items, which is: MutableMap<Double, Double>:

val areas = mutableListOf<MutableMap<Double, Double>>()

Then you can add maps to it:

areas += mutableMapOf(1.0 to 1.0)
Related