Example of the Scala aggregate function

前端 未结 7 945
傲寒
傲寒 2020-12-22 19:07

I have been looking and I cannot find an example or discussion of the aggregate function in Scala that I can understand. It seems pretty powerful.

Can t

7条回答
  •  遥遥无期
    2020-12-22 19:30

    The definition of aggregate in TraversableOnce source is:

    def aggregate[B](z: B)(seqop: (B, A) => B, combop: (B, B) => B): B = 
      foldLeft(z)(seqop)
    

    which is no different than a simple foldLeft. combop doesn't seem to be used anywhere. I am myself confused as to what the purpose of this method is.

提交回复
热议问题