I have a list on which I'd like to apply some transformations, but excluding the first 2 elements. How can I do it the nicest way? Something like this:

list.reversed().take(list.size - 2)...(my transformations)

or

list.excludeFirstN(2)...(my transformations)

推荐答案

Oh, I found the drop() function.

Kotlin相关问答推荐

我可以检测一个函数是否在Kotlin中被递归调用(即,重入)吗?

调用即发即忘方法--哪个作用域?

如何确保Kotlin子类已完成初始化?

Kotlin stlib中是否有用于将列表<;对<;A,B&>;转换为对<;列表<;A&>,列表<;B&>;的函数

在Spring Boot应用程序中使用网络请求功能将关键字挂起作为冗余

在 Kotlin 中,为什么我们要在闭包中捕获值

为什么使用 return instance ?: synchronized(this) { instance ?: PreferenceParameterState(context) } 时无法获得单例?

MyType.()在 Kotlin 中是什么意思?

为什么这个 Kotlin 代码不起作用? (如果 str[index] 在列表中,则打印)

为什么 IntelliJ Idea 无法识别我的 Spek 测试?

来自类型参数的属性的自定义 getter

retrofit 响应代码 405 并带有消息method not allowed here

如何将 kotlin 集合作为 varagrs 传递?

是否可以在 kotlin 中嵌套数据类?

Kotlin:找不到符号类片段或其他 android 类

如何在 Spring WebFlux 的响应正文中流式传输二进制数据

封闭 lambda 的隐式参数被shadowed

如何为 Java 调用者声明返回类型为void的 Kotlin Lambda?

Kotlin,什么时候按map授权?

Kotlin 是否支持部分应用程序?