Boolean logic question [closed]
"true"? "Yes" : "No" , I am using rub开发者_JAVA百科y language
This is taking by deafult "yes" even I select "no"
value = condition ? value-if-true : value-if-false
is a shortcut for this
if condition == true
value = value-if-true
else
value = value-if-false
If you have a condition that is always evaluated as true, you will always have value-if-true
. In the example code "true"
is always a true expression. The only values which are treated as false in an expression are false
and nil
.
It's a little hard to tell what you're taking, but the value "true"
is a string. For the boolean value, you want just true
, with no quotation marks.
精彩评论