kotlin
  • Kotlin
  • Variable
  • Function
  • First Class Citizen
  • High Order Function
  • Pure Function
  • Call by Value, Call by Name
  • Null Safe
  • Generic
  • Expression
    • if - else
    • when
    • try - catch
    • while
    • for
  • Class
    • abstract
    • constructor
    • Data Class
    • Default Value
    • enum
    • inheritance
    • interface
    • open
    • property
    • sealed
  • Kotlin Standard
    • let
    • with
    • apply
    • run
    • also
    • takeIf
    • takeUnless
    • use
    • repeat
  • Collections
    • Mutable
    • Immutable
    • Collections
    • Aggregate operations
      • any
      • all
      • count
      • fold
      • foldRight
      • fold vs foldRight
      • forEach
      • forEachIndexed
      • max
      • maxBy
      • min
      • minBy
      • none
      • reduce
      • reduceRight
      • sum
      • sumBy
    • Filtering operations
      • drop
      • dropLast
      • dropWhile
      • dropLastWhile
      • filter
      • filterNot
      • slice
      • take
      • takeLast
      • takeWhile
    • Mapping operations
      • map
      • mapIndexed
      • flatMap
      • groupBy
    • Elements operations
      • contains
      • elementAt
      • elementAtOrElse
      • elementAtOrNull
      • first
      • firstOrNull
      • indexOf
      • indexOfFirst
      • indexOfLast
      • last
      • lastIndexOf
      • lastOrNull
      • single
      • singleOrNull
    • Generation operations
      • partition
      • plus
      • minus
      • zip
      • unzip
    • Ordering operations
      • reversed
      • sorted
      • sortedBy
      • sortedDescending
      • sortedByDescending
Powered by GitBook
On this page
  1. Collections

Collections

val list = listOf(1, 2, 3)
val mutableListOf = mutableListOf(1, 2, 3)

val set = setOf(1, 2, 3)
val mutableSet = mutableSetOf(1, 2, 3)

val map = mapOf(1 to "1", 2 to "2", 3 to "3")
val mutableMap = mutableMapOf(1 to "1", 2 to "2", 3 to "3")

  • Kotlin 은 Java 와 다르게 mutable, immutable 2가지의 collection 이 존재한다.

  • mutable 은 변경 가능한 collection 을 말한다.

  • immutable 은 변경 불가능한 collection 을 말한다.

  • mutable prefix 가 없는 자료구조는 기본적으로 immutable 이다.

PreviousImmutableNextAggregate operations

Last updated 6 years ago