Skip to content

Instantly share code, notes, and snippets.

@Kazuki-Kachi
Created December 19, 2017 11:27
Show Gist options
  • Save Kazuki-Kachi/c37f3cdde7e7e8ed4a71c3d2c6048776 to your computer and use it in GitHub Desktop.
Save Kazuki-Kachi/c37f3cdde7e7e8ed4a71c3d2c6048776 to your computer and use it in GitHub Desktop.
For func
// scalaは言わずものかな
val f:Int => Int = args.headOption match {
case Some(value) => x => + catching(classOf[NumberFormatException]).opt(value.toInt).getOrElse(0)
case None => x => x
}
// そもそも宣言で型がわかっているので
val f1:Int => Int = args.headOption match {
case Some(value) => _ + catching(classOf[NumberFormatException]).opt(value.toInt).getOrElse(0)
case None => _
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment