kotlin-lateinit Questions
3
Solved
I am using Dagger2 for DI in my Android app, and using this code for injecting classes into my Activity is fine:
@field:[Inject ApplicationContext]
lateinit var context: Context
but, lateinit mo...
Schaumberger asked 23/6, 2017 at 9:13
12
Solved
Just curious: In Kotlin, I would love to get some val that can be initialized by lazy, but with a parameter. That's because I need something that's created very late in order to initialize it.
Spe...
Subduct asked 25/1, 2018 at 12:41
3
Solved
I'm trying to check if a lateinit property has been initialized.
In Kotlin 1.2 we now have the isInitialized method for that. It works when I do that in the class where the lateinit property is dec...
Propagation asked 29/11, 2017 at 9:15
1
I want to check the lateinit propery initialized or not inside an extension method.
I want to execute simple function call to lateinit property safely inside an extenstion method.
I can use this::...
Publicness asked 25/5, 2020 at 7:22
2
Solved
This is a straight forward question but I cannot find an answer. Is there a way to be notified when a lateinit var has been initialised in Kotlin?
I know I can check if it has been initialised wit...
Dried asked 7/12, 2017 at 1:32
1
I have a lateinit var as
lateinit var someVariable: SomeVariable
I initialize this value like someVariable = SomeVariable() and use it whenever I need.
At a certain point, I want to set everyth...
Vendace asked 11/10, 2019 at 6:11
6
Solved
Why can't we use lateinit with nullable variables?
lateinit var v: String?
lateinit modifier is not allowed on properties of nullable types
Stellite asked 29/5, 2019 at 5:44
1
Solved
Member lateinit variables initialization can be checked with:
class MyClass {
lateinit var foo: Any
...
fun doSomething() {
if (::foo.isInitialized) {
// Use foo
}
}
}
However this synta...
Irritation asked 8/2, 2019 at 22:17
4
Solved
I am in the process of learning Kotlin, and reading about the lateinit keyword makes me doubt its usefulness. Consider this code:
var testString: String? = null
lateinit var lateTestString: Strin...
Flatware asked 10/1, 2018 at 13:7
2
Solved
In my Activity I have a lateinit property called controller that my Fragment uses.
This property is initialized in Activity.onCreate(). My Fragment gets its reference back to my Activity through on...
Ebonieebonite asked 5/1, 2018 at 11:6
1
Solved
I want to use this feature
the simplest thing like in the example does not work for me:
lateinit val foo = 1
val bar = foo::lateinitVar.isInitialized()
But I am getting
unresolved reference l...
Burley asked 17/12, 2017 at 23:1
3
Solved
I have the following Kotlin class on Android:
class ThisApplication: Application() {
lateinit var network: INetwork
override fun onCreate() {
super.onCreate()
network = Network()
}
}
No...
Leal asked 20/8, 2017 at 0:2
3
Solved
In Kotlin, suppose, I have class:
class MyKotlinClass {
lateinit var field: String
}
According to docs:
Late-Initialized properties are also exposed as fields. The visibility of the field wi...
Signe asked 15/3, 2017 at 11:23
1
© 2022 - 2025 — McMap. All rights reserved.