mikezx6r (11) [Avatar] Offline
#1
This example:

fun sum(list: List<Int>): Int = if (list.isEmpty())
        0 
    else
        list[0] + sum(list.subList(1, list.size))


The last line can be re-written using the `drop` function. Concise, and I find it very readable.

list[0] + sum(list.drop(1))
Pierre-Yves Saumont (164) [Avatar] Offline
#2
Hi,

You're absolutely right.

Thanks