私はscalaを学び始めたばかりです。再帰関数を実装しようとしているときに、Eclipse で「不正な単純式の開始」というエラーが発生しました。
def foo(total: Int, nums: List[Int]):
if(total % nums.sorted.head != 0)
0
else
recur(total, nums.sorted.reverse, 0)
def recur(total: Int, nums: List[Int], index: Int): Int =
var sum = 0 // ***** This line complained "illegal start of simple expression"
// ... other codes unrelated to the question. A return value is included.
(再帰)関数内で変数を定義することについて私が間違っていたことを誰か教えてもらえますか? オンラインで検索しましたが、このエラーを説明することはできません。