I'm trying to write extension for AssertK that wil...
# announcements
i
I'm trying to write extension for AssertK that will deep compare objects ignoring id. Works well if I use
T:Any
but fails when I want to support nullable fields. Any idea how to cast other to not null type so I can access it class.members?
Copy code
fun <T : Any?> assertk.Assert<T>.isEqualToIgnoringId(
    other: T
) {
    all {
        if (other == null)
            this.isEqualTo(null)
        else
            other?.let { it::class.members }
    }
}
k
What if you make
T
extend
Any
and then use
Assert<T?>
and
other:T?
?
i
worked, thanks 🙂