Skip to content

Instantly share code, notes, and snippets.

@sonumehrotra
Created March 24, 2021 18:11
Show Gist options
  • Save sonumehrotra/8b8d6262735b25046eb26f67139abecd to your computer and use it in GitHub Desktop.
Save sonumehrotra/8b8d6262735b25046eb26f67139abecd to your computer and use it in GitHub Desktop.
enum MyList[+T]:
case Cons(head: T, tail: MyList[T])
case EmptyList
def isEmpty: Boolean = this match {
case Cons(_, _) => false
case EmptyList => true
}
def prepend[R >: T](element: R): MyList[R] = Cons(element, this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment