Skip to content

Releases: L-Briand/either

Version 1.2.1

09 Feb 09:58
Compare
Choose a tag to compare

Adding kotlin contract to all functions.

It is now possible to chain consecutive functions which returns Either of the same kind with the try operator.

object Error
fun String.toInt(): Either<Int, ERROR> = this.toIntOrNull()?.let { Left(it) } ?: Right(ERROR)
fun Int.inBound(range: IntRange): Either<Int, ERROR> = if (this in range) Left(this) else Right(ERROR)

val data: Either<String, ERROR> = Left("123")
val result: Int = data.tryLeft(String::toInt)
    .tryLeft { it.inBound(0..<100) }
    .requireLeft { return }

assertEquals(123, result)

Version 1.2.0

08 Dec 10:34
Compare
Choose a tag to compare

Library is now available on:

  • Jvm
  • javascript: js / wasmjs
  • All native kotlin target platforms.
    • macosX64
    • macosArm64
    • iosSimulatorArm64
    • iosX64
    • linuxX64
    • linuxArm64
    • watchosSimulatorArm64
    • watchosX64
    • watchosArm32
    • watchosArm64
    • tvosSimulatorArm64
    • tvosX64
    • tvosArm64
    • iosArm64
    • androidNativeArm32
    • androidNativeArm64
    • androidNativeX86
    • androidNativeX64
    • mingwX64
    • watchosDeviceArm64

Full Changelog: https://github.com/L-Briand/either/commits/version-1.2.0