In a Scala program, a semicolon at the end of a statement is usually optional.
val s = "hello"; println(s)
The rules of semicolon inference
1. The line in questing ends in a word that would not be legal as the end of a statement, such as period or an infix ooperator.
2. The next line begins with a word that cannot start a statement.
3. The line ends while inside parentheses (...) or brackets [...], because these cannot contain multiple statements anyway.
댓글 없음:
댓글 쓰기