With equals sign:
object HelloWorld {
def main(args: Array[String]) = {
println("Hello!")
}
}
Without equals sign:
object HelloWorld {
def main(args: Array[String]) {
println("Hello!")
}
}
Both of the above programs execute the same way. In the blog post Things I do not like in Scala I read that when the equals sign are missing, the method will return Unit
(same as Java's void
), so methods that return a value must use the equals sign. But methods that don't return a value can be written either way.
What is the best practice for using the equals sign in Scala methods that don't return a value?