equals - How to compare two arrays in Kotlin? -


given arrays in kotlin

let = arrayof("first", "second") val b = arrayof("first", "second") val c = arrayof("1st", "2nd") 

are there built-in functions kotlin std-lib tests 2 arrays (value) equality each element?

thus resulting in:

a.equals(b) // true a.equals(c) // false 

equals() returning false in both cases, maybe there built-in functions kotlin 1 use?

there static function java.utils.arrays.deepequals(a.totypedarray(), b.totypedarray()) rather prefer instance method work better optionals.

kotlin 1.1 introduced extensions comparing arrays content: contentequals , contentdeepequals.

these extensions infix, can use them following way:

val areequal = arr1 contentequals arr2 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -