assertEquals
compares these sets as equal in the code like yours, same as the equality operator.
import kotlin.test.assertEquals
fun main(args: Array<String>) {
//sampleStart
data class OtherType(val value: String) {}
class MyType {
var values : MutableSet<OtherType> = mutableSetOf()
}
val myValue = "test"
val myObject = MyType().apply { values.add(OtherType(myValue)) }
println(setOf(OtherType(myValue))::class)
println(myObject.values::class)
println(setOf(OtherType(myValue)) == myObject.values)
assertEquals(setOf(OtherType(myValue)), myObject.values)
//sampleEnd
}
So the reason why you see the other result must be something else.