Klitos Kyriacou
09/26/2023, 8:57 PMArrayList
now has a reversed()
method that does what Kotlin's asReversed()
does (returns a reversed view of the original collection), will this new reversed()
method cause any confusion with Kotlin's existing reversed()
function which returns a new List?ephemient
09/26/2023, 9:22 PMforEach
)val a: List<Any?> = ArrayList()
a.reversed() // calls Kotlin extension
(a as java.util.List<Any?>).reversed() // calls Java default method
Klitos Kyriacou
09/26/2023, 9:41 PMfun foo(list: ArrayList<Int>) {
list.reversed() // calls Kotlin extension
if (list is SequencedCollection<*>)
list.reversed() // calls Java method
}
Loney Chou
09/27/2023, 1:43 AM