Skip to content

Collections: Transform a collection into a single result

Devrath edited this page Feb 29, 2024 · 1 revision

code

val inputNo = arrayOf(1,2,3)

fun main(args: Array<String>) {

    val output = inputNo.reduce { result, item ->
        result + item
    }

   println("Result-> $output")

}

output

Result-> 6
Clone this wiki locally