i have following spark code snippet .
but following error:
:8: error: missing parameter type.
which happens here:
val index:int= col1(i) ; tokened +=splitted(index) + " " ; } } ^
i can't work out steps seems i've specified properties. need return string method string => string (currently it's string -> unit) first time ever coding in scala apologies if stupid question
line => { var col1:array[int] = array(1,2) ; var tokened:string = "" ; var splitted:array[string]=line.split(" ") ; (i<- 0 col1.length) { val index:int= col1(i); tokened +=splitted(index) + " " ; } }
i guess need:
(line: string) => { /* missing type annotation */ var col1:array[int] = array(1,2) var tokened:string = "" var splitted:array[string]=line.split(" ") (i<- 0 col1.length) { val index:int= col1(i) tokened += splitted(index) + " " } tokened /* return value */ }
in order make function type explicit, store anonymous function in function-typed variable:
val f: (string => string) = line => { ... }
Comments
Post a Comment