What is a shorthand in kotlin for java's code? `St...
# announcements
w
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
wilddev: Yeah, you need to use arrayOf several times. There are no collection literals in Kotlin.
s
(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
Those literals only work in annotations though, so won't help here
😒 1
m
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.