It'd be nice to have python's sublist syntax in ko...
# announcements
h
It'd be nice to have python's sublist syntax in kotlin At the moment you can accomplish some of it like this:
Copy code
operator fun List<Int>.get(range: IntRange) = subList(range.start, range.endInclusive - 1)

val foo = listOf(1,2,3,4)
val bar = foo[0..2] // [1,2,3]
But I think
foo[1..]
and
foo[..3]
would be great too, even though you can accomplish them each with a single list method, this looks nicer imo That would require the
rangeTo
operator to create unbounded ranges, though, but I think it'd be nice to have that, too. Thoughts?