0% found this document useful (0 votes)
125 views

mutableSetOf - Kotlin Programming Language PDF

The document describes the mutableSetOf function in Kotlin, which returns an empty mutable set or a mutable set initialized with the given elements. mutableSetOf returns a MutableSet that preserves element insertion order and allows modifying the set by adding, removing, or replacing elements.

Uploaded by

Riaan smith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

mutableSetOf - Kotlin Programming Language PDF

The document describes the mutableSetOf function in Kotlin, which returns an empty mutable set or a mutable set initialized with the given elements. mutableSetOf returns a MutableSet that preserves element insertion order and allows modifying the set by adding, removing, or replacing elements.

Uploaded by

Riaan smith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 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

You might also like