Kotlin Training Program

DOWNLOAD APP

FEEDBACK

Reverse

To reverse a collection, we can use the reversed() function. It create & returns a new list in reversed order :

 // Syntax :
coll.reversed()
 

Example :

 fun main() {
		val nums = listOf(1, 2, 3)
		println(nums.reversed())
}

// Output : [3, 2, 1]