Reputation: 121
Following this post http://obviam.net/index.php/libgdx-and-kotlin/ I created a project, and edited using Atom. It compiles, and runs on an android device. I want to convert to AndroidStudio for better tooling.
I'm using AndroidStudio 1.5.1, and it says I have the latest version of the kotlin plugin. I created a new project using the LibGDX setup program, imported into AdroidStudio, converted the main class to kotlin, everything works. Then I pasted in my existing my code, and when I build, this line:
val bullets:MutableList<NewBullet> = linkedListOf()
gets this error:
Error:(19, 42) Unresolved reference: linkedListOf
When I select Tools -> Kotlin -> Configure it says 'All modules with Kotlin files are configured'.
I've also tried importing the existing project into AndroidStudio, and the result is the same issue.
Upvotes: 3
Views: 3388
Reputation: 148089
As said in the change log of Kotlin 1.0 RC, linkedListOf
has been deprecated and is not available now. The article you referenced uses Kotlin 1.0 Beta, which is older.
To create a LinkedList<T>
from varargs, you can pass a listOf(...)
to the constructor:
val bullets: MutableList<SomeType> = LinkedList(listOf(item1, item2))
or write your own linkedListOf
:
fun <T> linkedListOf(vararg items: T) = LinkedList<T>().apply {
for (i in items) { add(i) }
}
Upvotes: 5