- Nil: the empty set
- Cons: a cell containing an element and the rest of the list
trait IntList ...
class Cons(val head: Int, val tail: IntList) extends IntList ...
class Nil extends IntList
The use of val is syntactic sugar for:
class Cons(_head: Int, _tail: IntList) extends IntList {
val head = _head
val tail = _tail
}
This saves the use of _head and _tail.
No comments:
Post a Comment