私は次の Scala コード、命令型スタイルを持っています。関数型スタイルに同等のものがあるかどうか疑問に思っていましたreturn
。
def function(c: Char, vector: Vector[Vector[Char]]): (x:Int , y:Int) = {
for (x <- vector.indices)
for (y <- vector(x).indices)
if (vector(x)(y) == c)
return (x, y)
throw new NoSuchElementException
}
を使用せずに、これと同じくらい効率的な代替手段があるかどうか疑問に思っていますreturn
。