任务是编写一个函数,该函数生成给定数量的整数,这些整数不大于另一个给定数字.我现在的代码看起来像这样:
scala> def lotto(count: Int, max: Int): Seq[Int] = { | var result = Seq[Int](); | var x: Int = 0; | for(x <- 1 to count){ | result = scala.util.Random.nextInt(max) :+ result | } | }:13: error: value :+ is not a member of Int result = scala.util.Random.nextInt(max) :+ result ^ :12: error: type mismatch; found : Unit required: Seq[Int] for(x <- 1 to count){ ^
它没有编译,你可以看到.有人可以解释这里有什么问题吗?