tjohnn
07/17/2019, 5:04 AMProduct
and ProductToOrder
which are quite similar in terms of id
and name
, I overrode the`equals()` already but productsToOrder?.indexOf<Any>(product)
always returns -1
Pavlo Liapota
07/17/2019, 6:44 AMequals
is a good idea in this case as you would need to override equals
and hashCode
in both classes.
Instead you can write:
productsToOrder.indexOfFirst {
it.id == product.id && it.name == product.name
}
tjohnn
07/17/2019, 7:11 AM