Be able to return vararg T

The proposal is very simple; be able to return vararg of something as a type.

Rather than this being a need (because you can always return a list or provide a list builder) I believe it would look very JSONy while designing DSLs. And maybe I am biased but I like it better with the lambda syntax than using the parentheses

fun notificationChannels(channelProvider: () -> (vararg NotificationChannel)) = channelProvider().toList()

val channels = notificationChannels {
     notificationChannel { /*builder code*/ },
     notificationChannel { /*builder code*/ }
}

vararg T isn’t a type right now it’s syntatic sugar to declare an array and pass it to a function.
What would be the return type of such a function? Array<T>?

I don’t really like the idea. I think the , is to easy to miss or forget when using a vararg return type.
Also lso you could easily build the same functionallity without a vararg return tpye.

fun notificationChannels(build: ChannelGroupBuilder.() ->  Unit): List<Channel>  {
    val builder = ChannelGroupBuilder()
    builder.build()
    return builder.list
}
fun ChannelGroupBuilder.notificationChannel(builder: () -> Channel) {
    list.add(builder())
}

val channels = notificationChannels {
     notificationChannel { /*builder code*/ }
     notificationChannel { /*builder code*/ }
}

Yes. Excuse my way to put it, but it could be cool to have the vararg syntactic sugar inside lambdas. So I would specify the lambda returns an Array<T> and be able to list each item as if I was calling arrayOf(i1,i2)