Parameterless Method in Scala
Prerequisites – Scala | Functions
A parameterless method is a function that does not take parameters, defined by the absence of any empty parenthesis. Invocation of a paramaterless function should be done without parenthesis. This enables the change of def to val without any change in the client code which is a part of uniform access principle.
There are generally two conventions for using parameter less method. One is when there are not any parameters. Second one is when method does not change the mutable state. One must avoid the invocations of parameterless methods which look like field selections by defining methods that have side-effects with parenthesis.
An example of calling a parameterless method with a parenthesis giving a Compilation error.
prog.scala:23: error: Unit does not take parameters
GFG.author() //calling method without parenthesis
one error found
Note: An empty parenthesis method can be called without parenthesis but it is always recommended and accepted as convention to call empty-paren methods with parenthesis.