Skip to content

Instantly share code, notes, and snippets.

@gkojax
Created October 10, 2012 09:46
Show Gist options
  • Save gkojax/3864426 to your computer and use it in GitHub Desktop.
Save gkojax/3864426 to your computer and use it in GitHub Desktop.
引数のうち数値のものだけ抽出してソートして標準出力する。
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