score:0

Is this helpful? isEmpty works great.

val strm = true #:: false #:: Stream[Boolean]()
def matchStream[T](stream:Stream[T]):List[String] = {
  stream match {
    case head #:: tail => head.toString :: matchStream(tail)
    case stm if stm.isEmpty => List("end of stream")
  }
}
matchStream(strm)

I ran this in a worksheet and got

res0: List[String] = List(true, false, end of stream)

Related Query

More Query from same tag