简体   繁体   中英

Scala => with =

I am trying to understand Spark internals and also new to Scala. I would like to ask the meaning of (index, res) => results(index) = res in this statement in SparkContext.scala:

runJob[T, U](rdd, func, partitions, (index, res) => results(index) = res)

source: SparkContext.scala

The two things that confound me is the usage of the => and = in the same expression, and the grouping/precedence (should it be interpreted with the => first, or = first then => ?).

The usage of => doesn't seem to match any of the usages of => i read online, and it's not clear what = res is doing.

Thanks!

(index, res) => ... means an anonymous function that receives two parameters ( index and res ).

results(index) = res is the body of the function.

What the function does is to assign res to results on the index position.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM