-4

I was trying to submit this code using spark submit. I found the following errors. I also would like to know how to do a function call in Scala and how do we start the function definition. I am calling file_reading function and I got the below error.

Here is my my function definition

def file_reading(file: String,val start:Int,val end:Int): Unit = {

Here are the Error I got:

/home/ram/sbt_project/src/main/scala/Scala_sample.scala:19:33: identifier expected but 'val' found.
[error]   def file_reading(file: String,val start:Int,val end:Int): Unit = {
[error]                                 ^
[error] /home/ram/sbt_project/src/main/scala/Scala_sample.scala:28:1: ':' expected but '}' found.
[error] }
[error] ^
[error] two errors found
Valy Dia
  • 2,781
  • 2
  • 12
  • 32
Fasty
  • 784
  • 1
  • 11
  • 34
  • The argument list of a def cannot contain the val keyword. This should read `def file_reading(file: String, start:Int, end:Int): Unit` – Terry Dactyl Nov 09 '18 at 13:41
  • Just remove the val from start and end and add val to hdfs_connect2 and location – koiralo Nov 09 '18 at 13:42

1 Answers1

2

Please remove val in the method.

 def file_reading(file: String,start:Int,end:Int): Unit = {

Please correct for loop, next you will be getting error here.

paths ??

for(each <- file) 
Kullayappa M
  • 174
  • 2
  • 14
  • Why shouldnt I give 'val'? – Fasty Nov 09 '18 at 14:01
  • you should not give sir, there are ways to follow. you can see the error, error: identifier expected but 'val' found. you can give it in case class like case class(var a:Int,val b:Int) – Kullayappa M Nov 09 '18 at 14:29