I'm having this class
class Product(val price: BigDecimal, val tag: String)
Then I add items to this class
var products = ArrayList<Product>()
for (i in 1..5) {
products.add(Product((0.25 * i).toBigDecimal(), i.toString()))
}
Now I can view the items like this
products.forEach {
Log.d("xxx", "price: ${it.price} tag: ${it.tag}")
}
Results:
D/xxx: price: 0.25 tag: 1
D/xxx: price: 0.5 tag: 2
D/xxx: price: 0.75 tag: 3
D/xxx: price: 1.0 tag: 4
D/xxx: price: 1.25 tag: 5
What I'm trying to do is, find "price" with "tag" = "3" in products.
I'm using this code but it gives me null.
var f = products.find { it.tag.equals('3') }
Any ideas?