Vararg vs. array parameter

I don’t want to get into a factual tussle here. I suspect you are confusing the JVM with a programming language that emits JVM byte codes (e.g. Java, Kotlin and others). They are quite different things. There is no concept of varargs in the JVM (specifically, in the Java Virtual Machine specification as updated). Period. The Java Programming language (note the distinction) compiles successfully if the call site has either a list or an array for a single target method with the … syntax as the last parameter in the method definition. In both cases, the Java compiler emits code that is a typed array. Kotlin is different - one person’s subjective description of which is better or less or more restrictive is irrelevant. It was my (naive) assumption that Kotlin would work the same way as Java in this regard. It doesn’t.

1 Like