Kotlin is designed to be fully interoperable with Java. Array<X>
is X[]
both at runtime and from Java’s point of view. Java arrays don’t implement Iterable
, so Kotlin arrays (which are virtually the same) do not as well.
We could make our arrays implement Iterable
by creating a standalone class which does not relate to Java arrays. However, in order to maintain compatibility with Java, we’d have to perform implicit conversions from such type to Java arrays and back. Implicit conversions are generally not the perfect approach because of performance overhead and unclear object identity semantics. Here they would also solve only a half of the problem, since you’d still have to manually “box” arrays when calling Kotlin code from Java. This is why such solution was not considered as feasible.