Closed
Description
Function from https://docs.scala-lang.org/scala3/book/taste-hello-world.html
@main def hello = println("Hello, world!")
is arity-0 and performs side effects, therefore it should look like this:
@main def hello() = println("Hello, world!")
https://docs.scala-lang.org/scala3/book/methods-most.html says:
A suggestion about methods that take no parameters
When a method takes no parameters, it’s said to have an arity level of arity-0. Similarly, when a method takes one parameter it’s an arity-1 method. When you create arity-0 methods:
If the method performs side effects, such as calling println, declare the method with empty parentheses If the method does not perform side effects—such as getting the size of a collection, which is similar to accessing a field on the collection—leave the parentheses off
For example, this method performs a side effect, so it’s declared with empty parentheses:
def speak() = println("hi")
Metadata
Metadata
Assignees
Labels
No labels