Parameterless Method in Scala Last Updated : 12 Jun, 2019 Comments Improve Suggest changes Like Article Like Report 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. Example: Scala // Scala program to illustrate // Parameterless method invocation class GeeksforGeeks(name: String, ar: Int) { // A parameterless method def author = println(name) def article = println(ar) // An empty-parenthesis method def printInformation() = { println("User -> " + name + ", Articles -> " + ar) } } // Creating object object Main { // Main method def main(args: Array[String]) { // Creating object of Class 'Geeksforgeeks' val GFG = new GeeksforGeeks("John", 50) GFG.author // calling method without parenthesis } } Output: John 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. Example: Scala // Scala program to illustrate // Parameterless method invocation class GeeksforGeeks(name: String, ar: Int) { // A parameterless method def author = println(name) def article = println(ar) // An empty-parenthesis method def printInformation() = { println("User -> " + name + ", Articles -> " + ar) } } // Creating object object Main { // Main method def main(args: Array[String]) { // Creating object of Class 'Geeksforgeeks' val GFG = new GeeksforGeeks("John", 50) GFG.author() //calling method without parenthesis } } Output: 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. Comment More infoAdvertise with us Next Article Parameterless Method in Scala V vishodushaozae Follow Improve Article Tags : Scala Scala Scala-Method Similar Reads Scala | Repeated Method Parameters In Scala, Repeated Method parameters are supported, which is helpful when we don't know the number of arguments a method requires. This property of Scala is utilized in passing limitless parameters to a method defined. Important points : The methods with Repeated Parameters should have each of the p 2 min read How to define Optional Parameter in Scala? Optional parameters in Scala provide us with a procedure or a way to define some default values for function parameters. The need to define default values comes when a value is not provided for the parameter during function invocation. These are also useful when we want to provide some default or sp 5 min read Scala | Method Invocation Method Invocation is a technique that demonstrates different syntax in which we dynamically call methods of a class with an object. The naming conventions of Scala are same as of Java, that are:- There should not be any space between the invocation object/target and the dot(.) nor a space between th 3 min read Scala | Methods to Call Option The Option in Scala is referred to a carrier of single or no element for a stated type. When a method returns a value which can even be null then Option is utilized i.e, the method defined returns an instance of an Option, in place of returning a single object or a null. There are a few methods that 5 min read Scala Int min() method with example The min() method is utilized to return the minimum value of the two specified int numbers. Method Definition: (First_Number).min(Second_Number)Return Type: It returns true the minimum value of the two specified int numbers. Example 1: Scala // Scala program of Int min() // method // Creating object 1 min read Like