W3cubDocs

/Kotlin

plusElement

Platform and version requirements: JVM (1.0), Native (1.3)
fun <T> Array<T>.plusElement(element: T): Array<T>
Platform and version requirements: JS (1.1)
fun <T> Array<out T>.plusElement(element: T): Array<T>

Returns an array containing all elements of the original array and then the given element.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> Iterable<T>.plusElement(element: T): List<T>
fun <T> Collection<T>.plusElement(element: T): List<T>

Returns a list containing all elements of the original collection and then the given element.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> Set<T>.plusElement(element: T): Set<T>

Returns a set containing all elements of the original set and then the given element if it isn't already in this set.

The returned set preserves the element iteration order of the original set.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/plus-element.html