dh44t
01/24/2018, 3:18 PMziggy42
01/24/2018, 3:24 PMvar total = getTotal()
val list = bankStatement.transactions.map {
val currentTotal = total
val totalBefore = currentTotal - it.amount
total = totalBefore
Something.fromThing(it, currentTotal, totalBefore)
}
dh44t
01/24/2018, 3:32 PMval currentTotal
is still totalziggy42
01/24/2018, 3:33 PMsome.things.map {
Something.fromOtherThing(it, currentTotal, currentTotal - it.amount).also {
currentTotal -= it.amount
}
}
dh44t
01/24/2018, 3:33 PMmenegatti
01/24/2018, 3:34 PMalso
because it might hinder readabilityziggy42
01/24/2018, 3:36 PM