Author | Message |
---|---|
rabbott
Posts: 1649
|
Posted 16:33 Nov 15, 2013 |
You have probably noticed that in the videos many methods are called without dots. That's another of Scala's ways to make code look more natural. Suppose you wanted to find the smaller of corresponding elements in two lists.
The final line could also be written like this.
The intent is to make Note also the convenience of using a (ns zip reverseNs) map (xy => xy match { case (x, y) => x min y } ) or (ns zip reverseNs) map (xy => xy._1 min xy._2 }) Note that to use a case construct in this way requires that you surround it with braces. It's really a shortened for the full match version.
Last edited by rabbott at
16:39 Nov 15, 2013.
|