75

How can I "skip" the first N entries of a kotlin sequence/list?

I am looking for the kotlin equivalent of C# LINQ "skip".

GameScripting
  • 16,092
  • 13
  • 59
  • 98

1 Answers1

119

You are probably looking for the "drop" function known for example from from lodash:

val seq = 1..10

seq.drop(5)
> [6, 7, 8, 9, 10]
GameScripting
  • 16,092
  • 13
  • 59
  • 98
  • 19
    Note that in your example `seq` is not a `Sequence`, but an `IntRange` which is `Iterable`. Nevertheless `drop` extension function is available both for `Sequence` and `Iterable`. – Ilya Apr 26 '17 at 20:07