import java.util.Random class Kostka { val rand = new Random(System.currentTimeMillis()) val value: List[Int] = List(rand.nextInt(6+1)) } object MyRandom { def Fill[A](n: Int): List[A] = { if (n<=0) Nil else { var lst = List[A] for (i <- 1 to n){ lst ++= (new Kostka).value } return lst } } } object Gra { def main(args: Array[String]): Unit = { println("Podaj liczbe kosci\n") val kosci: List[Kostka] = MyRandom.Fill[Kostka](10) // Policzenie wyniku println("Strzelaj ile razem wypadło\n") // przyjecie wyniku // dopisac ile wypadlo czyli wynik println("Wypadlo: ") println(kosci.toString) } } And error:
a.scala:10: error: missing arguments for method apply in object List; follow this method with `_' if you want to treat it as a partially applied function var lst = List[A] ^ one error found When I have:
var lst = List[A]() i got that error:
a.scala:12: error: type mismatch; found : List[Any] required: List[A] lst ++= (new Kostka).value ^ one error found