Nolan
08/26/2021, 3:37 PM===
, and all of my unit tests passed. However, once deployed, the filter function did not work as expected. I wrote an simple JVM app to see if it was an issue with JVM specifically, but in that case "str" === "str"
resolved to true, which is not the behavior I was seeing in my Spring Boot app. Any ideas why I'd be seeing this discrepancy in the Spring Boot app?Dariusz Kuc
08/26/2021, 3:42 PMNolan
08/26/2021, 4:02 PMit === "str"
would always be false, which is what I was seeing in my Spring Boot app. However, this is not the behavior I was seeing in my unit tests or in the simple JVM console app.
My simple JVM console app:
class StringListWrapper(val stringList: List<String>) {
fun goodWordsOnly() = stringList.filter { "GOOD" === it }
}
fun main() {
val stringWrapper = StringListWrapper(listOf("BAD", "BADDER", "BADDEST", "GOOD"))
println("${stringWrapper.stringList.joinToString(",")} is unfiltered")
println("${stringWrapper.goodWordsOnly().joinToString(",")} is filtered")
}
Output:
BAD,BADDER,BADDEST,GOOD is unfiltered
GOOD is filtered
Dariusz Kuc
08/26/2021, 4:48 PM===
is referential integrity check meaning that both references point to the same object in memoryDariusz Kuc
08/26/2021, 4:49 PM==
which is structural integrity (i.e. whether object contents are equal) -> note: in Java ==
is a referential integrity check vs .equals
using structural integrity checkDariusz Kuc
08/26/2021, 4:52 PMval x = "foo"
val y = "foo"
println(x == y)
println(x === y)
val z = String("foo".toByteArray())
println(x == z)
println(x === z)
Nolan
08/26/2021, 6:48 PMmolikuner
08/26/2021, 6:54 PMCLOVIS
08/28/2021, 4:33 PM==
on strings. Always. If they point to the same reference, it will shortcut and be 0(1). If they don't point to the same reference, it will check the contents, which is O(n).