I have list of objects T
and I want to calculate their sum (T
objects)
var objects: Observable<List<T>>
T
object has a method which return Int
value.
The main idea to get each object and prepare array of values (flatMap
function). The next step will be reduce
func with Int
values.
let sum = values.reduce(0) { $0 + $1 }
Q: How to get each T
object?