Instead of use `val mobileMain by creating {...}`,...
# multiplatform
g
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
Do you want all the source sets in a map or just a subset?
The former is more or less done for you.
g
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
sourceSets
is a map of all your source sets.
g
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 😃