Created
January 27, 2012 02:39
-
-
Save masahitojp/1686632 to your computer and use it in GitHub Desktop.
pattern matchの練習。Regexpでpattern matchして数値文字列を変換する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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