-2

I have some code below

   val primitiveDS = Seq(1, 2, 3).toDS()
   primitiveDS.map(_ + 1).collect() // Returns: Array(2, 3, 4)

I want to know what exactly underscore meaning here (_ + 1), I know this belongs to scala mixed identifiers, I searched lot but could not get the exact meaning.

Also share some link to get it in depth of

indra
  • 832
  • 4
  • 17
  • 33

1 Answers1

0

map(x=>x+1) short form is map(_+1). It is a short form to access the element

loneStar
  • 3,780
  • 23
  • 40
  • Could you please point to some document to understand more about these – indra Sep 24 '18 at 11:34
  • How to understand this------------ ranks .join(stationVertices) .sortBy(_._2._1, ascending=false) // sort by the rank .take(10) // get the top 10 .foreach(x => println(x._2._2)) – indra Sep 24 '18 at 11:45