filterNotTo
所在位置是kotlin.text.filterNotTo
,其相關用法介紹如下。
用法:
inline fun <C : Appendable> CharSequence.filterNotTo(
destination: C,
predicate: (Char) -> Boolean
): C
將所有不匹配給定 predicate 的字符附加到給定 destination 。
例子:
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val numbers: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7)
val evenNumbers = mutableListOf<Int>()
val notMultiplesOf3 = mutableListOf<Int>()
println(evenNumbers) // []
numbers.filterTo(evenNumbers) { it % 2 == 0 }
numbers.filterNotTo(notMultiplesOf3) { number -> number % 3 == 0 }
println(evenNumbers) // [2, 4, 6]
println(notMultiplesOf3) // [1, 2, 4, 5, 7]
//sampleEnd
}
輸出:
[] [2, 4, 6] [1, 2, 4, 5, 7]
相關用法
- Kotlin filterNotTo用法及代碼示例
- Kotlin filterNot用法及代碼示例
- Kotlin filterNotNull用法及代碼示例
- Kotlin filterNotNullTo用法及代碼示例
- Kotlin filterKeys用法及代碼示例
- Kotlin filterTo用法及代碼示例
- Kotlin filterIsInstance用法及代碼示例
- Kotlin filterIsInstanceTo用法及代碼示例
- Kotlin filterIndexedTo用法及代碼示例
- Kotlin filterValues用法及代碼示例
- Kotlin filter用法及代碼示例
- Kotlin filterIndexed用法及代碼示例
- Kotlin findLast用法及代碼示例
- Kotlin find用法及代碼示例
- Kotlin firstNotNullOf用法及代碼示例
- Kotlin firstNotNullOfOrNull用法及代碼示例
- Kotlin flatten用法及代碼示例
- Kotlin forEach用法及代碼示例
- Kotlin flatMap用法及代碼示例
- Kotlin fold用法及代碼示例
- Kotlin foldTo用法及代碼示例
- Kotlin flatMapIndexed用法及代碼示例
- Kotlin associateBy用法及代碼示例
- Kotlin all用法及代碼示例
- Kotlin map用法及代碼示例
注:本文由純淨天空篩選整理自kotlinlang.org大神的英文原創作品 kotlin.text.filterNotTo。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。