For a solution which uses just the size, and not a...
# announcements
j
For a solution which uses just the size, and not a range:
Copy code
fun <T> newList(size: Int, supplier: (Int) -> T): List<T> {
    val result = ArrayList<T>(size)
    for (i in 0 until size) {
        result.add(supplier(i))
    }
    return result
}

fun main(args: Array<String>) {
    val list = newList(5) {
        100 + it
    }
}