Negative index and default value filled

Maybe we can let List.slice support negative index and default value?
Such as: If we want to get recently 7 days price from a list to fill a charts, we can: prices.slice(-7..-1){ 0 }
If the list only have three days price. It will use the default value { index -> 0 }

emmm…There is a implement emmm xD

Thank you.

1 Like

If you want it in the standard library, I think the best you can do, is to file an issue in YouTrack.

Somewhat related: How can I get Python's slice operator in Kotlin - Stack Overflow