Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- AWS
- collection
- Swift
- CLASS
- class component
- elementAt
- lifecycle
- Generic
- Foreign Key
- 생명주기
- Kotlin
- enum
- Service
- map
- react native
- animation
- docker-compose
- recyclerview
- MINUS
- mongoose
- list
- ReactNative
- ConstraintLayout
- docker
- LiveData
- Interface
- vuex
- union
- function
- Filter
Archives
- Today
- Total
개발 일기
plus and minus Operators 본문
코틀린에서는 plus(+) 와 minus(-)가 collection에 정의가 되어있습니다.
plus
plus는 기존에 있었던 첫번째 collection에 뒤에 있는 값들을 연속적으로 포함을 시킵니다.
minus
minus는 기존에 있었던 첫번째 collection에 뒤에 있던 값들을 하나씩 제거를 진행합니다.
만약에 collection인 경우에는 해당 요소들이 다 제거가 됩니다.
또 다른 방법으로는 "plusAssign(+=) 하는 방법도 있지만 minusAssign(-=)
이 방식들은 read-only로 반환하지 않습니다.
val numbers = mutableListOf("one", "two", "three", "four")
numbers += "five"
val plusList = numbers + "six"
val minusList = numbers - listOf("three", "four")
println(plusList)
println(minusList)
[one, two, three, four, five, six]
[one, two, five]
'컴퓨터 언어 > kotlin' 카테고리의 다른 글
Retrieving Collection Parts (0) | 2020.05.28 |
---|---|
Grouping (0) | 2020.05.27 |
Filtering (0) | 2020.05.25 |
Collection Transformations (0) | 2020.05.22 |
Sequences (0) | 2020.05.21 |
Comments