kotlin get last element of list
val myList = listOf(1, 2, 3, 4, 5)
// Step 1: Check if the list is not empty
if (myList.isNotEmpty()) {
// Step 2: Use the last() function to get the last element of the list
val lastElement = myList.last()
// Step 3: Print or use the last element as needed
println("Last Element: $lastElement")
} else {
println("The list is empty.")
}