private val routes = mapOf<Regex, (vararg args: String) -> LaunchAction?>(
I would like to accept a variable number of arguments in that anonymous function defined as the map’s value, how can I do that? I’m not allowed to set a modifier like
vararg
there
y
Youssef Shoaib [MOD]
03/15/2022, 1:10 PM
vararg
is syntatic sugar for Arrays, so use
args: Array<String>
instead like so:
Copy code
private val routes = mapOf<Regex, (args: Array<String>) -> LaunchAction?>(
o
oday
03/15/2022, 1:10 PM
oh..
oday
03/15/2022, 1:11 PM
lol ok TIL
oday
03/15/2022, 1:11 PM
thanks
👍 1
r
Ruckus
03/15/2022, 9:14 PM
As the old adage goes
Don't use an array unless you need an array. If you don't know if you need an array, you don't need an array.