https://kotlinlang.org logo
#announcements
Title
# announcements
w

wilddev

06/29/2017, 6:28 PM
What is a shorthand in kotlin for java's code?
Copy code
String[][] table = {
	{"a","b","c"},
	{"d","e","f"},
	{"g","h","i"},
	{"j","k","l"},
};
Should I use arrayOf in every line?
d

dalexander

06/29/2017, 6:31 PM
wilddev: Yeah, you need to use arrayOf several times. There are no collection literals in Kotlin.
s

shbr.bcks

06/30/2017, 8:07 AM
(I have not upgraded yet so don't know for sure!) Extract from 1.2 Release Notes:
>>
Language feature: array literals in annotations The single notable language feature proposed in this milestone is array literals, whose usages are constrained to annotation arguments. Earlier one had to write something like following to specify an array of values: @CacheConfig(cacheNames = arrayOf("books", "default")) public class BookRepositoryImpl { // .... } In Kotlin 1.2 a literal can be used instead of the arrayOf function: @CacheConfig(cacheNames = ["books", "default"]) public class BookRepositoryImpl { // .... }
r

robhor

06/30/2017, 9:43 AM
Those literals only work in annotations though, so won't help here
😒 1
m

mrtact

06/30/2017, 7:36 PM
At that point, since you have to make function calls anyway, I would probably write some little helper classes to parse out a delimited format.