Skip to content

Instantly share code, notes, and snippets.

@masahitojp
Created January 27, 2012 02:39
Show Gist options
  • Save masahitojp/1686632 to your computer and use it in GitHub Desktop.
Save masahitojp/1686632 to your computer and use it in GitHub Desktop.
pattern matchの練習。Regexpでpattern matchして数値文字列を変換する
val r = """^(\d+)$""".r
var hoge = "123456789" match {
case r(n) => n.toInt
case _ => println("Do not matched")
}
val huga = Array("9876") match {
case n if n.size ==1 =>
n(0) match {
case re(t) => t.toInt
case _ => 8080
}
case _ => 8080
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment