The takeLastWhile function also accepts a lambda expression. This function takes elements from the end of a list until the condition is not satisfied:
newList = numbers.takeLastWhile { it > 5 }
println("Take all elements from end of the list, which are greater than 5")
println(newList)
Here, the output is [8, 9, 10]. The takeLastWhile function starts executing from the end of the list and stops executing when the given condition becomes false.