Skip to content

Instantly share code, notes, and snippets.

@nelanka
Last active August 29, 2015 14:13
Show Gist options
  • Save nelanka/2018790c01e079d92679 to your computer and use it in GitHub Desktop.
Save nelanka/2018790c01e079d92679 to your computer and use it in GitHub Desktop.
Map an Option to a Scalactic Or
object OptionToOr {
implicit class PimpedOption[T](opt: Option[T]) {
def orError(error: String): T Or Every[String] = opt match {
case Some(value) => Good(value)
case None => Bad(One(error))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment