Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 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)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement