简体   繁体   English

未指定的值参数:用于Scala中的数组

[英]Unspecified value parameters: for array in Scala

 def rearrange(str: String) = {
    var indexes = Array[Int]()
    indexes = allIndexes(0, str, indexes)
    indexes foreach( println(_) )
  }

  def allIndexes(position: Int, str: String, tokens: Array[String], indexes: Array[Int]): Array[Int] ={
    tokens foreach( (e) => {
      var pos = str.indexOf(e, position)
      if (pos != -1){
        return allIndexes(pos, str, (indexes:+ pos))
      }else{
        return indexes
      }
    })
  }

在此处输入图片说明 What it complaining about? 它抱怨什么? How to solve it? 怎么解决呢?

The method allIndexes requires 4 parameters, but you call the method only with 3 arguments. allIndexes方法需要4个参数,但是仅使用3个参数调用该方法。 Thus, the compiler is complaining that the parameter indexes is unspecified. 因此,编译器抱怨参数indexes未指定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM