Created
October 10, 2012 09:46
-
-
Save gkojax/3864426 to your computer and use it in GitHub Desktop.
引数のうち数値のものだけ抽出してソートして標準出力する。
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
import scala.util.control.Exception._ | |
object Main { | |
def main(args : Array[String]) : Unit = { | |
args.toList.filter(allCatch either _.toInt isRight).sorted.foreach(println) | |
} | |
} | |
// 数値かどうかをチェックするのに、toInt関数を呼んで例外が発生するかどうかでチェックするとか | |
// 良いやりかたでは無いと思います。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment