object Main{
def main(args: Array[String]){
val head = List(1, 2, 3) match {
case (head :: tail) => head
case Nil => -1
}
val head2 = List() match {
case (head :: tail) => head
// 空のときのパターンを書かないとコンパイラが警告を出す。
// Test.scala:8: warning: match may not be exhaustive.
// It would fail on the following input: Nil
// val head2 = List() match {
// one warning found
//
//
}
}
}