I have the following Java 11 code (the contents of arr1 and arr2 are not so simple in my code, and I have more than 2 arrays, but the concept is the same):
String[] arr1 = new String[] {"a","b"};
String[] arr2 = new String[] {"c", "d"};
var req = Stream.of(arr1, arr2).flatMap(Stream::of).toArray(String[]::new);
The purpose of this code is to take all the values in multiple arrays of Strings and produce a single String array out. It needs to be an array, not a collection, due to an API outside my control accepting a String array later in the code.
In this simple example, the resulting array should have the following elements in this order: { "a", "b", "c", "d" }.
What is the canonical way to flatten a 1-deep array of arrays into a single array in Kotlin?
The main reason I'm being thrown for a loop here is that the IntelliJ Java to Kotlin converter did a pretty bad job of converting this code, leaving it with multiple weird syntax errors in the output Kotlin. The rest of my code that doesn't use things like method references converted much more cleanly to Kotlin.