2024-06-21
This commit is contained in:
60
Writerside/topics/Collection.md
Normal file
60
Writerside/topics/Collection.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# 컬렉션
|
||||
|
||||
- listOf()
|
||||
|
||||
- setOf()
|
||||
|
||||
- mapOf()
|
||||
|
||||
- mutableListOf()
|
||||
|
||||
- mutableSetOf()
|
||||
|
||||
- mutableMapOf()
|
||||
|
||||
|
||||
```kotlin
|
||||
val numberSet = setOf("one", "two", "three")
|
||||
val emptySet = mutableSetOf<String>()
|
||||
```
|
||||
|
||||
```kotlin
|
||||
val numberMap = mapOf("one" to 1, "two" to 2, "three" to 3)
|
||||
```
|
||||
|
||||
## 빌더 함수
|
||||
|
||||
- buildList()
|
||||
|
||||
- buildSet()
|
||||
|
||||
- buildMap()
|
||||
|
||||
|
||||
```kotlin
|
||||
val map = buildMap{
|
||||
put("a", 1)
|
||||
put("b", 2)
|
||||
}
|
||||
```
|
||||
|
||||
## 빈 컬렉션
|
||||
|
||||
- emptyList()
|
||||
|
||||
- emptySet()
|
||||
|
||||
- emptyMap()
|
||||
|
||||
|
||||
```kotlin
|
||||
val empty = emptyList<String>()
|
||||
```
|
||||
|
||||
## 복제
|
||||
|
||||
- toList()
|
||||
|
||||
- toMutableList()
|
||||
|
||||
- toSet()
|
||||
Reference in New Issue
Block a user