In the language future survey, the item 8 is “Slices for lists and arrays”.
I don’t really understand why would the language need enhancement while this would really easilly done by the stdlib:
operator fun <T> List<T>.get(r: IntRange) = subList(r.start, r.endInclusive + 1)
operator fun <T> List<T>.get(r: IntRange, step: Int) = subList(r.start, r.endInclusive + 1).filterIndexed { index, _ -> index % step == 0 }
fun main(args: Array<String>) {
val list = listOf(0, 1, 2, 3, 4, 5)
println(list[1..4])
println(list[1 until 4])
println(list[1..4, 2])
}
What would be the benefit of adding a new language syntax?