Hi, I really like `buildList` and I was wondering...
# announcements
p
Hi, I really like
buildList
and I was wondering if there is a way to use it without having to write
@ExperimentalStdlibApi
everywhere.
l
Just a follow-up question to this. Is it possible to only opt in to
buildList
rather than all
@ExperimentalStdlibApi
functions? I would like to be able to have more granular control of APIs that are an accepted risk, rather than allowing them all. Unless I've read it incorrectly, it seems that you would need a unique annotation per method experiential function at the moment.
l
Just implement your own…
Copy code
inline fun <E> buildList (action: MutableList<E>.() -> Unit): List<E> {
    val list= mutableListOf<E> ()
    list.action ()
    return list
}
l
I know it's reasonably easy to do so. But if you did that for every kotlin API, your code would become quite unmanageable
a
No, it's not possible. Please consider creating an issue at http://kotl.in/issue and describing your use case. Thanks!
l
Thanks @Alexey Belkov [JB]. Will look into it