Calculate average - a shorter way
When you have a collection of Transactions objects and want to
calculate its average amount, instead of looping through the collection
like this:
1 2 3 4 5 | |
you can reduce the loop to 1 line of code, using Objective-C key-value coding:
1
| |
Currently, there is a fixed set of collection operators:
- Simple collection operators (
@avg,@count,@sum,@max,@min) - Object operators (
@distinctUnionOfObjects,@unionOfObjects) - Array and set operators (
@distinctUnionOfArrays,@unionOfArrays)