In groovy, why would we add floats like this:
class SomeCommand {
Float a = 0
Float b = 0
Float c = 0
Float d = 0
Float e = 0
Float f = 0
Float getTotal() {
[a, b, c, d, e, f].findAll { it }.sum() as Float
}
not simply like this:
class SomeCommand {
Float a = 0
Float b = 0
Float c = 0
Float d = 0
Float e = 0
Float f = 0
Float getTotal() {
return a + b + c + d + e + f
}
Essentially my question is: What is the advantage or benefit of using sum on a collection over simply adding them up?