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

后端 未结 5 1022
予麋鹿
予麋鹿 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:50

    I have found the solutions.

    First the underscore here is as placeholder.

    To make a function literal even more concise, you can use underscores as placeholders for one or more parameters, so long as each parameter appears only one time within the function literal.

    See more about underscore in Scala at What are all the uses of an underscore in Scala?.

提交回复
热议问题