Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
Added test that required head tail pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
emoen committed May 26, 2013
1 parent d791d6c commit ec39678
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -67,5 +67,19 @@ class ListMatchingTest extends EmptyTest {
assertEquals(subList(0), mathedElement)
}


// @Test
def matchNestedElementOfListWithHeadTailPatternMatching {
val subList = List("Indeed", "it", "is")
val list = List("Scala", "is", "powerful", subList)

// Here you must find the first element of the second sublist
// like in the example above but using head tail pattern matching
def findSublist(listOfList:List[Any]): String = list match {
// Insert you match statement here
case _ => "failed"
}
val mathedElement = findSublist(list)

assertEquals(subList(0), mathedElement)
}
}

0 comments on commit ec39678

Please sign in to comment.