Reputation:
For example i have the following trait:
trait Some {
def method // i can omit the return type
val field: Some // i can't
}
If i omit the type of an abstract field it will raise a compile error, but not in case of a method?
Upvotes: 1
Views: 64
Reputation: 21557
It's drop-dead simple. If you omit the return type of an abstract method,
then Scala compiler will infer it as a Unit
(after typer phase):
abstract trait Some extends scala.AnyRef {
def method: Unit;
<stable> <accessor> def field: String
}
Upvotes: 2