Daniele B
09/03/2020, 8:45 PMval obj1 = MyDataObj(1,3,4)
val obj2 = MyDataObj(3,2,3)
val obj3 = MyDataObj(2,4,1)
val list = listof(obj1,obj2,obj3)
I would like to derive objTot
, which has a=6, b=9, c=8Evan
09/03/2020, 8:47 PMCasey Brooks
09/03/2020, 8:49 PMreduce
to use the first object in the list as the starting accumulator, instead of manually specifying one. https://pl.kotl.in/JFktqNpTrCasey Brooks
09/03/2020, 8:51 PMreduce
is for when you are “collapsing” values into a single object of the same type as the originals. fold
is when you’re collapsing those values into a different type, or you want to manually specify the starting state for accumulationCasey Brooks
09/03/2020, 8:52 PMDaniele B
09/03/2020, 9:02 PM