Scala Tutorial - Scala Semicolons








Semicolons are expression delimiters and they are inferred.

Scala treats the end of a line as the end of an expression, except when it can infer that the expression continues to the next line, as in this example:

Example

The following Trailing equals sign indicates more code on the next line.

     def equalsign(s: String) = 
       println("equalsign: " + s) 

The following Trailing opening curly brace indicates more code on the next line.

     def equalsign2(s: String) = { 
       println("equalsign2: " + s) 
     } 

The following Trailing commas, periods, and operators indicate more code on the next line.

      def commas(s1: String, 
                s2: String) = Console. 
       println("comma: " + s1 + 
               ", " + s2)