Issue
I am trying to learn Kotlin so I am just starting out. I have two files, the main file and a class file. I declared my package in the class file, then imported the class in the main file. However, when I try to run the program, the compiler says I have a reference error.
main.kt:
package test.app
import test.app.Rectangle
fun main() {
val rectangle = Rectangle(6.0, 5.0)
println(rectangle.perimeter)
}
Rectangle.kt:
package test.app
class Rectangle(var length: Double, var height: Double) {
var perimeter = (length + height) * 2
}
This is probably a simple issue, however I am not experienced enough in Kotlin to find a solution. Any help would be appreciated.
Solution
Everything is fine! Make sure you updated kotlin plugin with latest version. And your IDE is up to date.
Answered By - charlie.7
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.