-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScala
19 lines (13 loc) · 979 Bytes
/
Scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# () => Int vs => Int
If you say f: () => Int, then you mean that "f takes no parameters and produces an Int".
If you say f: => Int, then you mean that "delay the execution of whatever statement produces
an Int value until we use it in this code (and re-evaluate it each time)".
Functionally, this ends up being basically the same as f: () => Int
(and internally is converted into the same Function0 class), but it has a different usage,
presumably to allow for a more compact form of closures (you always omit the => in the calling code).
http://stackoverflow.com/questions/3855595/what-is-the-scala-identifier-implicitly
Scala 2.8 allows a shorthand syntax for implicit parameters, called Context Bounds. Briefly, a method with a type parameter A that requires an implicit parameter of type M[A]:
def foo[A](implicit ma: M[A])
can be rewritten as:
def foo[A: M]
https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-streaming-windowedoperators.html