I mean not the syntax itself, but decent samples. ...
# language-proposals
o
I mean not the syntax itself, but decent samples. E.g. I have a data class
Configuration(val host: String, val port: Int, val filters: List<Filter>)
and I want to build a
Map<String, List<Configuration>>
. How would it look like?
👍🏼 2
i
According to the proposal something like:
Copy code
["config1" : Configuration("host1", 80, []),
 "config2" : Configuration("host2", 8080, [Filter(...)])
]
o
Copy code
["config1" : [Configuration("host1", 80, []), Configuration("host1", 81, [])],
 "config2" : [Configuration("host2", 8080, [Filter(...)])]
]
Should be like this then
i
Oh, didn't spot List<Configuration>
o
Okay, now if I need
Map<String, Set<Configuration>>
instead?
i
That's where a lot of casting/type specification is required. Or you can specify an expected type of map.
b
@orangy :
Copy code
val j: Map<String, Set<Configuration>> = [
    "config1" : [
        Configuration("host1", 80, []),
        Configuration("host1", 81, [])
    ],
    "config2" : [
        Configuration("host2", 8080, [Filter(...)])
    ]
]
👍 1