Created
August 11, 2016 10:34
-
-
Save travisdachi/cbe44e614cba26977b5ee2b123d66bd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeActivity : Activity() { | |
val f: Foo by lazy { createFoo() } // put your initialization block here | |
fun onCreate(bundle: Bundle?) { | |
f.foo() // f will be created here and it's a val so you can't change it | |
f // or you can call a getter just to initialize it | |
} | |
fun createFoo() = Foo(this) | |
// this is useful when you need a context after the activity is created | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment