Skip to content

Instantly share code, notes, and snippets.

@vlasovskikh
Created May 24, 2013 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vlasovskikh/5644014 to your computer and use it in GitHub Desktop.
Save vlasovskikh/5644014 to your computer and use it in GitHub Desktop.
// Is it possible to shorten collection->array conversion in Kotlin?
fun f(): Array<String> {
val xs = setOf("foo", "bar")
return xs.toArray(Array(xs.size, { "" }))
}
@vlasovskikh
Copy link
Author

Yes, it is:

fun f(): Array<String> {
  val xs = setOf("foo", "bar")
  return xs.toArray(array<String>())
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment