2016-09-18 195 views

回答

3

this報價:

The following types of expressions can be made into a statement 
by terminating the expression with a semicolon (;). 

Assignment expressions 
Any use of ++ or -- 
Method invocations 
Object creation expressions 

... 

In addition to expression statements, there are two other kinds of 
statements: declaration statements and control flow statements. 

顯然,你的代碼線以上不屬於上述任何一類。因此,編譯器會引發錯誤。看看最外層,而不是內層。

4

The:?運算符用於返回值不是對if/else的完全替換,並且您沒有返回值。但更好地解釋什麼是完整的錯誤,並更好地看待代碼,而不僅僅是你發佈的行。