Skip to content
Snippets Groups Projects
Commit c580f3b0 authored by Lars Hupel's avatar Lars Hupel Committed by Etienne Kneuss
Browse files

change List.contains to use pattern matching without guards

parent dbca9036
No related branches found
No related tags found
No related merge requests found
...@@ -22,8 +22,7 @@ sealed abstract class List[T] { ...@@ -22,8 +22,7 @@ sealed abstract class List[T] {
} }
def contains(v: T): Boolean = (this match { def contains(v: T): Boolean = (this match {
case Cons(h, t) if h == v => true case Cons(h, t) => h == v || t.contains(v)
case Cons(_, t) => t.contains(v)
case Nil() => false case Nil() => false
}) ensuring { _ == (content contains v) } }) ensuring { _ == (content contains v) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment