All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.harmony.kotlin.common.either.EitherUtils.kt Maven / Gradle / Ivy

package com.harmony.kotlin.common.either

/**
 * Transform a block of code into a Either
 */
inline fun  eitherOf(block: () -> R): Either {
  return try {
    Either.Right(block())
  } catch (e: Throwable) {
    if (e is L) {
      Either.Left(e)
    } else {
      throw e
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy