I have the following snippet of scala code:
def append(as: List[Int], bs: List[Int]): List[Int] = as match {
case Nil => bs
case x::xs => x::append(xs, bs)
}
I don't understand the x::
in the line where x::append(xs, bs)
is. I know that when the list as
is empty then bs
will be returend (with an appended as
when as
was not empty before). But how does scala know in the mentioned line that is should append as
to bs
with x::(..,..)