주어진 요소가 처음으로 나타나는 경우 없이 원본 컬렉션의 모든 요소를 포함하는 목록을 반환합니다.
public operator fun <T> Iterable<T>.minus(elements: Iterable<T>): List<T> {
val other = elements.convertToListIfNotCollection()
if (other.isEmpty())
return this.toList()
return this.filterNot { it in other }
}
val string = "HelloWorld"
val intArray = intArrayOf(0, 1, 2, 3)
print(string.indices - intArray.toSet()) // [4, 5, 6, 7, 8, 9]
minus - Kotlin Programming Language
kotlinlang.org
'코틀린 > [Generation] 생성 작업' 카테고리의 다른 글
[Kotlin][Collection] joinToString (0) | 2024.08.29 |
---|---|
[Kotlin][Collection] plus (0) | 2024.08.21 |