Define multiple variables at once in Kotlin (e.g J

2019-04-18 01:34发布

问题:

This question already has an answer here:

  • How to declare several properties on one line 2 answers

I was wondering if there is any way to define multiple variables in Kotlin at once like in Java and almost every other existing language in the world .

like in Java :

String x="Hello World!",y=null,z;

回答1:

This is not possible in Kotlin language.

Please refer to this question and answer, where JetBrains' Engineer yole states that:

"Declaring multiple properties on the same line is frowned upon by many Java style guides, so we did not implement support for that in Kotlin."