Вы находитесь на странице: 1из 2

13/02/2020 mutableSetOf - Kotlin Programming Language

Kotlin Heroes Coding Challenge Take Part!

1.3.61 Learn Community Play

Overview
Common JVM JS Native Version 1.3

kotlin-stdlib / kotlin.collections / mutableSetOf


What's New

Getting Started
mutableSetOf
Basics
1.1
Classes and Objects
fun <T> mutableSetOf(): MutableSet<T>
Functions and Lambdas Returns an empty new MutableSet.

Collections The returned set preserves the element iteration order.

Coroutines
val set = mutableSetOf<Int>()
println("set.isEmpty() is ${set.isEmpty()}") // true
Multiplatform Programming
set.add(1)
More Language Constructs set.add(2)
set.add(1)
Core Libraries
println(set) // [1, 2]
Reference
set.isEmpty() is true
Java Interop [1, 2]

JavaScript Target platform: JVM Running on kotlin v. 1.3.61

Native

Tools

Evolution fun <T> mutableSetOf(vararg elements: T): MutableSet<T>


Returns a new MutableSet with the given elements. Elements of the set are iterated in the order they
FAQ
were speci ed.

val set = mutableSetOf(1, 2, 3)


println(set) // [1, 2, 3]

set.remove(3)
set += listOf(4, 5)
println(set) // [1, 2, 4, 5]

[1, 2, 3]
[1, 2, 4, 5]
Target platform: JVM Running on kotlin v. 1.3.61

Blog Forum Bug tracker Github Twitter

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/mutable-set-of.html 1/2
13/02/2020 mutableSetOf - Kotlin Programming Language
Contributing to Kotlin

Press kit
Sponsored and developed by
Licensed under the Apache 2 license
Kotlin Trademark is protected under the Kotlin Foundation

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/mutable-set-of.html 2/2

Вам также может понравиться