I apologize in advance for my programming political incorrectness, as I do not know what the thing I need to type is called.
I have this Java code.
FrutasVerduras frutasVerduras_datos[] = new FrutasVerduras[] {
}
How would this be written in Kotlin?
That thing is called an array. Currently, in Kotlin you can't create them using the same syntax as in Java. Though that's going to change (see "Language feature: array literals in annotations") a little in the near future. The Kotlin way to do it is using arrayOf(...). Keep in mind though that for basic types you should use the adequate function (e.g. for Int use intArrayOf) as otherwise the JVM will create an array of Integers (object) instead of int (primitive) causing 12 (?) bytes more per element
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With