addAll
Adds all of the elements of the specified collection to this collection.
Since Kotlin
1.0Return
true
if any of the specified elements was added to the collection, false
if the collection was not modified.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.addAll(listOf('a', 'b', 'c')) is ${list.addAll(listOf('a', 'b', 'c'))}") // true
println(list) // [a, b, c, a, b, c]
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val set = mutableSetOf('a', 'b', 'c')
// All three elements are in set, nothing will be added
println("set.addAll(listOf('a', 'b', 'c')) is ${set.addAll(listOf('a', 'b', 'c'))}") // false
// At least one element will be added, 'd'
println("set.addAll(listOf('a', 'b', 'c', 'd')) is ${set.addAll(listOf('a', 'b', 'c', 'd'))}") // true
println(set) // [a, b, c, d]
//sampleEnd
}
Adds all of the elements of the specified collection to this collection.
Since Kotlin
1.1Return
true
if any of the specified elements was added to the collection, false
if the collection was not modified.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.addAll(listOf('a', 'b', 'c')) is ${list.addAll(listOf('a', 'b', 'c'))}") // true
println(list) // [a, b, c, a, b, c]
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val set = mutableSetOf('a', 'b', 'c')
// All three elements are in set, nothing will be added
println("set.addAll(listOf('a', 'b', 'c')) is ${set.addAll(listOf('a', 'b', 'c'))}") // false
// At least one element will be added, 'd'
println("set.addAll(listOf('a', 'b', 'c', 'd')) is ${set.addAll(listOf('a', 'b', 'c', 'd'))}") // true
println(set) // [a, b, c, d]
//sampleEnd
}
Adds all of the elements of the specified collection to this collection.
Since Kotlin
1.0Return
true
if any of the specified elements was added to the collection, false
if the collection was not modified.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.addAll(listOf('a', 'b', 'c')) is ${list.addAll(listOf('a', 'b', 'c'))}") // true
println(list) // [a, b, c, a, b, c]
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val set = mutableSetOf('a', 'b', 'c')
// All three elements are in set, nothing will be added
println("set.addAll(listOf('a', 'b', 'c')) is ${set.addAll(listOf('a', 'b', 'c'))}") // false
// At least one element will be added, 'd'
println("set.addAll(listOf('a', 'b', 'c', 'd')) is ${set.addAll(listOf('a', 'b', 'c', 'd'))}") // true
println(set) // [a, b, c, d]
//sampleEnd
}
Adds all of the elements of the specified collection to this collection.
Since Kotlin
1.3Return
true
if any of the specified elements was added to the collection, false
if the collection was not modified.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.addAll(listOf('a', 'b', 'c')) is ${list.addAll(listOf('a', 'b', 'c'))}") // true
println(list) // [a, b, c, a, b, c]
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val set = mutableSetOf('a', 'b', 'c')
// All three elements are in set, nothing will be added
println("set.addAll(listOf('a', 'b', 'c')) is ${set.addAll(listOf('a', 'b', 'c'))}") // false
// At least one element will be added, 'd'
println("set.addAll(listOf('a', 'b', 'c', 'd')) is ${set.addAll(listOf('a', 'b', 'c', 'd'))}") // true
println(set) // [a, b, c, d]
//sampleEnd
}
Adds all of the elements of the specified collection to this collection.
Since Kotlin
1.8Return
true
if any of the specified elements was added to the collection, false
if the collection was not modified.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.addAll(listOf('a', 'b', 'c')) is ${list.addAll(listOf('a', 'b', 'c'))}") // true
println(list) // [a, b, c, a, b, c]
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val set = mutableSetOf('a', 'b', 'c')
// All three elements are in set, nothing will be added
println("set.addAll(listOf('a', 'b', 'c')) is ${set.addAll(listOf('a', 'b', 'c'))}") // false
// At least one element will be added, 'd'
println("set.addAll(listOf('a', 'b', 'c', 'd')) is ${set.addAll(listOf('a', 'b', 'c', 'd'))}") // true
println(set) // [a, b, c, d]
//sampleEnd
}
Adds all of the elements of the specified collection to this collection.
Since Kotlin
1.8Return
true
if any of the specified elements was added to the collection, false
if the collection was not modified.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.addAll(listOf('a', 'b', 'c')) is ${list.addAll(listOf('a', 'b', 'c'))}") // true
println(list) // [a, b, c, a, b, c]
//sampleEnd
}
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val set = mutableSetOf('a', 'b', 'c')
// All three elements are in set, nothing will be added
println("set.addAll(listOf('a', 'b', 'c')) is ${set.addAll(listOf('a', 'b', 'c'))}") // false
// At least one element will be added, 'd'
println("set.addAll(listOf('a', 'b', 'c', 'd')) is ${set.addAll(listOf('a', 'b', 'c', 'd'))}") // true
println(set) // [a, b, c, d]
//sampleEnd
}