为什么我不能将 'Val' 放在函数定义参数中。错误“:”预期但弹出“}”发现

Why can't I put 'Val' in function definition arguments. Error ':' expected but '}' found pops up

我正在尝试使用 spark submit 提交此代码。我发现了以下错误。我还想知道如何在 Scala 中进行函数调用以及我们如何开始函数定义。我正在调用 file_reading 函数,但出现以下错误。

这是我的函数定义

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

这是我得到的错误:

/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

请删除方法中的val。

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

请更正for循环,接下来你会在这里得到错误。

路径 ??

for(each <- file)