Exit Full View

Feather2 / documentation / VarArgs.md

VarArgs

Here's an example of how vararg types are defined :

static fun main( args : String... ) {
}

Which is equivalent to this Kotlin code :

@JvmStatic
fun main( vararg args : String ) {
}

Note how Kotlin splits the type into two parts : vararg before the parameter name, and String after the parameter name. IMHO, this split is bad; the type should only appear after the name.

Also, feather considers varargs as a convenient way to pass an array into a function. Not the only way; you may also pass in the array directly. So these are equivalent :

// Feather Coder
main( "Hello", "World" )

val arguments = arrayOf<String>( "Hello", "World" )
main( arguments )

main( arrayOf<String>( "Hello", "World" ) )

There is no need for the * operator (aka spread) which Kotlin requires :

// Kotlin Code
main( "Hello", "World" )
val arguments = arrayOf( "Hello", "World" )
main( * arguments )

main( * arrayOf( "Hello", "World" ) )

Back to Contents