WrapBoolean

data class WrapBoolean<R>(val condition: Boolean, val result: R?)

一个kotlin实现的类似三元表达式,甚至由于语言的特性,可以用来返回函数:

val r = true `?` { "r:true" } `:` { "r:false" }
val r1 = false `?` "" `:` "r:false"

Constructors

Link copied to clipboard
constructor(condition: Boolean, result: R?)

Properties

Link copied to clipboard
Link copied to clipboard
val result: R?

Functions

Link copied to clipboard
infix inline fun <R> WrapBoolean<R>.(ifFalse: R?): R?