Skip to content

Commit

Permalink
Add doctests for Ior.fromOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
markus1189 committed Dec 6, 2017
1 parent 22ce4c2 commit 765699d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/src/main/scala/cats/data/Ior.scala
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ private[data] sealed trait IorFunctions {
* @return `None` if both `oa` and `ob` are `None`. Otherwise `Some` wrapping
* an [[Ior.Left]], [[Ior.Right]], or [[Ior.Both]] if `oa`, `ob`, or both are
* defined (respectively).
*
* Example:
* {{{
* scala> Ior.fromOptions(Option.empty[String], Option.empty[Int])
* res0: Option[Ior[String, Int]] = None
* scala> Ior.fromOptions(Option.empty[String], Some(42))
* res1: Option[Ior[String, Int]] = Some(Right(42))
* scala> Ior.fromOptions(Some("Error"), Option.empty[Int])
* res2: Option[Ior[String, Int]] = Some(Left(Error))
* scala> Ior.fromOptions(Some("Warning"), Some(42))
* res3: Option[Ior[String, Int]] = Some(Both(Warning,42))
* }}}
*/
def fromOptions[A, B](oa: Option[A], ob: Option[B]): Option[A Ior B] =
oa match {
Expand Down

0 comments on commit 765699d

Please sign in to comment.