/** * High Order Functions * that execute function only in debug build variant */ fun debugMode(function: () -> Unit) { if (BuildConfig.DEBUG) { function() } } /** * How to use the code above */ class MyActivity : Activity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) debugMode { addInterceptor(loggingInterceptor) } } }