unless someone has a better idea
# announcements
d
unless someone has a better idea
z
So you would
Copy code
var total = getTotal()
val list = bankStatement.transactions.map {
    val currentTotal = total
    val totalBefore = currentTotal - it.amount
    total = totalBefore
    Something.fromThing(it, currentTotal, totalBefore)
}
d
that should work
Not sure why you need
val currentTotal
is still total
ok, I see it
z
@menegatti suggested something better:
Copy code
some.things.map { 
    Something.fromOtherThing(it, currentTotal, currentTotal - it.amount).also {
            currentTotal -= it.amount
    }
}
d
yeah
m
tbh, not sure it is better… I get a bit cautious around
also
because it might hinder readability
it is smaller, but I’d definitely say the way the total amount is being used is funky
z
My version was very ugly imho. I like yours a lot more