Server Side Kotlin-07

Server Side Kotlin-07

·

1 min read

Flatten:-

It provides flat access to nested collection elements .
flatten () is a collection of collections, for example, array of array, a List of Sets or List of List. The function returns a single collection of all the elements of the nested collections.

val numberSets = listOf(setOf(11, 22, 33), setOf(44, 55, 66), setOf(77,88))
println(numberSets.flatten())   
```   
output:-   
`[11, 22, 33, 44, 55, 66, 77, 88]`    
**joinToString()**  builds a single String from the collection elements based on the provided arguments.   
``` 
val numbers = listOf("blue", "red", "orange", "pink")

println(numbers)         
println(numbers.joinToString())  
```     
output    
`[blue, red, orange, pink]`     
`blue, red, orange, pink`