https://kotlinlang.org logo
e

egslava

02/27/2016, 2:27 PM
or:
Copy code
inline fun asrtr(condition: Boolean, lazyMessage: ()->String, badCase: ()->Unit) {
    if (!condition) {
        if (BuildConfig.DEBUG) {
            throw RuntimeException(lazyMessage())
        } else {
            badCase()
            return
        }
    }
}
Using:
Copy code
asrtr( asset.is_active != null, { "Asset.is_active == null!" }, err )

        if (asset._is_active){
          ...
       }