usage patterns pattern guard tuple regular expression Option unapply case class usage val (x, y) = (1, 2) //分解して代入 x = 1, y = 2 (x, y) match { case (1, 2) => "one, two" //パターンで分岐 case _ => "what?" } any match { case 1 => //定数パターン case _: Int => //型付きパターン case (_, _) => //タプルパターン case List(_, _, _) => //固定長シーケンスパターン case List(_, _*) => //_*で任意長シーケンスパターン case Some(x) => //コンストラクタパターン case x => //変数パ