https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

GarouDan

03/16/2019, 7:23 PM
Instead of use
val mobileMain by creating {...}
, can we put this result in a map, without creating a new
val
? For example, something similar to:
myMap["mobileMain"] by creating {...}
(do not compile) My motivation is that I would like to create a helper method to store sourceSets in a map, since I would like to consult this map later. The
creating
delegation is using something like:
Copy code
operator fun provideDelegate(thisRef: Any?, property: KProperty<*>) = ExistingDomainObjectDelegate.of(
        when (configuration) {
            null -> container.create(property.name)
            else -> container.create(property.name, configuration)
        }
    )
d

Dominaezzz

03/16/2019, 7:41 PM
Do you want all the source sets in a map or just a subset?
The former is more or less done for you.
g

GarouDan

03/16/2019, 7:55 PM
What do you mean when you say
the former
? It looks like I’ve found an workaround
Copy code
val myMap = mutableMapOf("mobileMain" to create("mobileMain"){...})
If possible I would like to store all my sourceSets on a map.
d

Dominaezzz

03/16/2019, 7:56 PM
sourceSets
is a map of all your source sets.
g

GarouDan

03/16/2019, 7:58 PM
I see, the problem was that I wasn’t find a way to create a new entry in the sourceSets without using the delegation method. But I think
create
solves the problem to me. Thanks 😃
2 Views