2014-04-02 4 views

답변

5

당신은 간단하게 수행 할 수 있습니다

if (!this.something) 

는 직접 부울 변수를 사용할 수 있습니다 :

예 : expression이 부울 값을 필요로하는 경우 때문에 다음과 같은

boolean flag = true; 
if(flag) { 
    //do something 
} 
1

사용.

if (!this.something) { 
// 
} 
0

부울 표현을 단순화하는 것은이 표현의 복잡성을 줄이고 의미를 보존하는 것입니다. 귀하의 경우에는

:

if(!this.something) 

는 같은 의미를 가지고 있지만 그것은 조금 짧은입니다.

더 복잡한 예제를 간소화하기 위해 진리표 또는 Karnaugh 맵을 사용할 수 있습니다.

0

문은 부울 경우

boolean something = true; 
if(something == true) evaluates to true 
if(something != true) evaluates to false 

로 내의 모든 것을 평가하기 원하지만 당신은 또한 또한

if(something) evaluates to whatever something is (true in this case) 
if(!something) evaluates to opposite what something is (false in this example) 

할 수 있다면 일반적으로 당신은 간단하게 할 수있는 경우에 사용하여 어떤 경우에 문 삼자 연산자 :

boolean isSomethingTrue = (something == true) ? true : false; 
boolean isSomethingTrue = something ? true : false; 
type variable = (condition) ? return this value if condition met : return this value if condition is not met; 
0

더 단순화를위한 삼항 연산자 :

someVariable은 1이 될 것입니다.

희망이 도움이됩니다.