You do not need to test case _
:
scala> @annotation.tailrec def printQ[A](p:Queue[A]) { | if(!p.isEmpty) { | p.dequeue match { | case (x,xs) => | println(x.toString) | printQ(xs) | } | } | } printQ: [A](p: scala.collection.immutable.Queue[A])Unit scala> printQ(Queue(1,2,4,5)) 1 2 4 5
Does it need to be recursive for a function?
scala> for (i <- Queue(1, 2, 4, 5)) println(i) 1 2 4 5
senia source share