Created
December 10, 2011 06:22
-
-
Save kxbmap/1454688 to your computer and use it in GitHub Desktop.
Scalazのminimum/maximumならOptionが返るから安心
This file contains 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
object Sample extends App { | |
val seq = Seq(1, 2, 3) | |
val empty = Seq[Int]() | |
println(seq.max) // -> 3 | |
// println(empty.max) // -> java.lang.UnsupportedOperationException: empty.max | |
import scalaz._, Scalaz._ | |
println(seq.maximum) // -> Some(3) | |
println(empty.maximum) // -> None | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment