je suit la définition du trait:Nil: Liste [Int] en tant que paramètre
sealed trait List[+A]
// `List` data type, parameterized on a type, `A`
case object Nil extends List[Nothing]
// A `List` data constructor representing the empty list
/* Another data constructor, representing nonempty lists. Note that `tail` is another `List[A]`,
which may be `Nil` or another `Cons`.
*/
case class Cons[+A](head: A, tail: List[A]) extends List[A]
et une fonction:
def add1(l: List[Int]): List[Int] =
foldRight(l, Nil:List[Int])((h,t) => Cons(h+1,t))
Ma question est, qu'est-ce que cela signifie Nil:List[Int]
? Est-ce que cela signifie, je passe une liste Nil
avec le type avec la notation Int
?
Ici, il est même que 'List.empty [Int]' – dveim