mkobit
11/26/2018, 4:38 PMOption<T>
where it is either a Some
or None
type, what is the best way to rite those?
for example, would it be better to have something like
fun Assertion.Builder<Option<T>>.isSome(asserts: Assertion.Builder<T>.() -> Unit)
or is there a better way to "chain" it where it short circuits the following assertions if it a None
?
fun Assertion.Builder<Option<T>>.isSome(): Assertion.Builder<T>
sandjelkovic
11/26/2018, 5:21 PMfun <T> Assertion.Builder<Option<T>>.isSome(valueAssertions: Assertion.Builder<T>.() -> Unit = {}): Assertion.Builder<T>
Should cover both cases.
If you're using Arrow Datatypes I already tried it like this for some of Datatypes, you can check it out at https://github.com/sandjelkovic/kombinator/blob/master/kombinator-spring-mvc/src/test/kotlin/com/sandjelkovic/kombinator/test/StriktExtensions.kt
It works greatmkobit
11/26/2018, 5:26 PM.isA<Some<T>>()
.get { t }
.and(valueAssertions)