Exists checks if a predicate holds for at least one element in the Traversable collection. For example:
def exists(p: ((A, B)) ⇒ Boolean): Boolean
Using the fat arrow: => is called the right arrow, fat arrow, or rocket and is used for passing parameters by name. That means the expression will be evaluated when a parameter is accessed. It is actually syntactic sugar for a zero parameter function call: x: () => Boolean. Let's see an example using this operator is as follows:
package com.chapter4.CollectionAPI
object UsingFatArrow {
def fliesPerSecond(callback: () => Unit) {
while (true) { callback(); Thread sleep 1000 }
}
def main(args: Array[String]): Unit= {
fliesPerSecond(() => println("Time and tide wait for none but fly like arrows ...