Apache-Spark : What is map(_._2) shorthand for?

后端 未结 5 1021
予麋鹿
予麋鹿 2020-12-28 08:59

I read a project\'s source code, found:

val sampleMBR = inputMBR.map(_._2).sample

inputMBR is a tuple.

the function

5条回答
  •  执笔经年
    2020-12-28 09:36

    Two underscores in '_._2' are different.

    First '_' is for placeholder of anonymous function; Second '_2' is member of case class Tuple.

    Something like:

    case class Tuple3 (_1: T1, _2: T2, _3: T3) {...}

提交回复
热议问题