https://kotlinlang.org logo
#feed
Title
# feed
e

ephemient

09/20/2023, 5:13 AM
yes there is a whole set of issues around initialization, https://youtrack.jetbrains.com/issues?q=tag:%20use-before-initialization
s

Shreyas Patil

09/20/2023, 5:23 AM
yeah
b

beholder

09/21/2023, 11:40 AM
It's not Kotlin specific, you can get same error in plain Java.
Copy code
public class Example
{
    Boolean value1 = computeValue1();
    String value2 = getData();
    Boolean computeValue1() {
        return value2.isEmpty();
    }
    static String getData() {
        return "SomeData";
    }
    public static void main(String[] args) {
        new Example();
    }
}
So Kotlin "breaks" nothing
s

Shreyas Patil

09/21/2023, 11:42 AM
In java, null-safety is not there. So it’s natural in Java But let’s say in kotlin
Copy code
val something: Type
something
is val declared as Non nullable type, so it becomes tricky to identify such issues in code review or debugging.