60 lines
567 B
Markdown
60 lines
567 B
Markdown
# 컬렉션
|
|
|
|
- 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() |