可能性の重複:
Scala immutable variables and printingなぜタイプミスマッチエラーですか?
私はそれが、私はそれを変更するために複数回試みていることを期待するとして、これは実行されませんし、それがまだあることを示すエラーを与える、なぜ私は混乱していますUnit
が与えられ、Int
が必要です。
def div(m: Int, n: Int): Int = {
var counter = 0
var p = m
while (p >= 0) {
p -= n
counter += 1
println(counter)
}
}
昨日この同じ質問に答えました。 http://stackoverflow.com/questions/7395682/scala-immutable-variables-and-printing – Dylan