I have done C/Java/C3/Python/JS
all my life. Since yesterday I am looking at some scala code, now i m super confused about everything..
The snippet goes:
// Parse the input file
val lines = fromTextFile(input)
// Iterate on every element to generate the keys, and then aggregate it
val counts = lines.mapFlatten{
line =>
val rowSplit = line.split(",",-1)
.... }
the signature of the method mapFlatten in scoobi api is :
def mapFlatten[B](f: (A) ⇒ Iterable[B])(implicit arg0: WireFormat[B]): DList[B]
Why do we call mapFlatten
with
mapFlatten{
instead of
mapFlatten({
Is it because the function is taking a predicate as a paramater?
in this sense, are while, else, if functions too?
According to this answer
Why use curly braces over parentheses?
there are cases when you do need to use curl braces(multiline expressions) and cases when you don't.
Indeed, they are all functions that receive functions inside.
In this situation:
You pass a function f:(A) that should result in Iterable[B]