When I have an abstract class with variables below
abstract class Book {
val id : Int
val name : String
val book : Long
}
Declaring them without types as
abstract class Book {
val id
val name
val book
}
Says incorrect value declaration. If methods can be declared without explicit type annotations.
abstract class Book {
val id : Int
val name : String
val book : Long
def aMethodWithNoTypeAnnotation
}
Why can't variables work the same way? Is this a limitation for the JVM?
source
share