Define several variables at once in Kotlin (for example, Java: String x, y, z;)

I was wondering if there is a way to define several variables in Kotlin at the same time, as in Java and almost all other existing languages ​​of the world.

like in java:

String x = "Hello World!", y = null, z; 
+26
source share
1 answer

This is not possible in Kotlin.

Please refer to this question and answer where the JetBrains yole engineer states that:

"Declaring multiple properties on the same line is unhappy with many Java style guides, so we have not implemented support for this in Kotlin."

+44
source

Source: https://habr.com/ru/post/1011953/


All Articles