package net.squanchy.support.lang

import arrow.core.Option
import arrow.core.getOrElse

fun <T> Option<T>.or(value: T): T {
    return this.getOrElse { value }
}

fun <T> Option<T>.getOrThrow(): T {
    return this.getOrElse { throw IllegalStateException("You must check if data is present before using get()") }
}

package net.squanchy.support.lang

import arrow.core.Option
import arrow.core.getOrElse

fun <T> Option<T>.or(value: T): T = this.getOrElse { value }

fun <T> Option<T>.getOrThrow(): T = this.getOrElse {
    throw IllegalStateException("You must check if data is present before using get()")
}

fun <T> T?.option(): Option<T> = Option.fromNullable(this)

Add option() extension fun to create optionals from nullables
Add option() extension fun to create optionals from nullables

squanchy-dev/squanchy-android,squanchy-dev/squanchy-android,squanchy-dev/squanchy-android