Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern matching LazyList #11750

charpov opened this issue Sep 26, 2019 · 1 comment


Copy link

commented Sep 26, 2019

This is a feature request. With the switch from Stream to LazyList, I have lost the possibility of pattern matching on Empty. I find myself writing things like:

val LazyNil = LazyList.empty

def getAt[A](s: LazyList[A], i: Int): A = (s, i) match {
  case (LazyNil, _) => throw new NoSuchElementException("getAt(empty)")
  case (h #:: _, 0) => h
  case (_ #:: t, _) => getAt(t, i - 1)

Is there a good reason the empty_ value from LazyList is not public? If not, could it be changed into a public Empty at some point?


This comment has been minimized.

Copy link

commented Sep 26, 2019


(note that Discourse is a better place for this kind of thing, when it's still at the question stage)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.