페이지

2015년 11월 2일 월요일

Scala2e Chapter4 Classes and Objects 4.2 Semicolon inference

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.




댓글 없음: