kevin-lee / just-fp

A small functional programming library

Home Page:https://just-fp.kevinly.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add toEither to OptionSyntax

kevin-lee opened this issue · comments

Task

Summary

Add toEither to OptionSyntax.

Project Details

Version: 1.1.0

Description

val maybeN = 1.some // Option[Int] = Some(1)
maybeN.toEither("Something wrong") // Either[String, Int] = Right(1)

val maybeN2 = none[Int] // Option[Int] = None
maybeN2.toEither("Something wrong") // Either[String, Int] = Left("Something wrong")