Anyone notice any code smells here? I was messing ...
# announcements
e
Anyone notice any code smells here? I was messing around trying to get an
unless
-like operator:
Copy code
sealed class Unless {
  object unless : Unless() {
    override val run: Boolean = false
  }
  
  object other : Unless() {
    override val run: Boolean = true
  }
  
  abstract val run: Boolean
}

inline infix fun Unless.otherwise(block: () -> Unit) {
  if(run) block()
}

inline fun unless(predicate: Boolean, block: () -> Unit): Unless =
    if(!predicate) {
      block(); Unless.unless
    }
    else {
      Unless.other
    }
g
Soo, is it just inverted if/else? if (!something) { // Do something } else { // do something else }