I have a question concerning the difference between these two functions:
def getFunction(checkpointPath: String,
sparkConf: SparkConf,
creatingFunc: () => StreamingContext): StreamingContext = {
function body
}
def getFunction(checkpointPath: String,
sparkConf: SparkConf,
creatingFunc: => StreamingContext): StreamingContext = {
function body
}
so the called by name param is the same:
creatingFunc: => StreamingContext
and
creatingFunc: () => StreamingContext
or no ?
The two are not the same. The first case specifies method parameter that is call-by-name
creatingFunc: => StreamingContext
whilst the second case specifies pass-by-value method parameter where the parameter happens to be a function of type () => StreamingContex
creatingFunc: () => StreamingContext
For example, consider the following two methods
def foo(arg: () => String) = ""
def foo(arg: => String) = ""
then
foo(() => "") // resolves to call first foo
foo("") // resolves to call second foo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With