How to get the last value of an ArrayList in kotlin?

Viewed 7830

How to get the last item of an ArrayList in kotlin?

I have a list like

val myList = listOf("item1", "item2", "item3")

I want to get the last item of myList

1 Answers

There's last() method, created exactly for this purpose.

myList.last()
Related