Skip to content

Instantly share code, notes, and snippets.

@hadilq
Created January 10, 2021 23:07
  • Select an option

Select an option

Revisions

  1. hadilq created this gist Jan 10, 2021.
    10 changes: 10 additions & 0 deletions ValidationResultElseIf.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    public inline infix fun ValidationResult.elseIf(build: ValidationResultElseIfBuilder.() -> Unit):
    Success {
    if (this is Success) {
    return this
    } else {
    val builder = ValidationResultElseIfBuilder(this)
    builder.build()
    return builder.result
    }
    }