Do you make sense to have a specialized function t...
# announcements
c
Do you make sense to have a specialized function to add an item to an immutable List?, something like this: (in the collections package i mean)
Copy code
fun <T> Collection<T>.plusHead(element: T): List<T> {
    val result = ArrayList<T>(size + 1)
    result.add(element)
    result.addAll(this)
    return result
}
n
listOf(element) + rest
💯 2
c
yeah! I never come up with the most obvious solution 😅
n
🙂