开发者

Boolean logic question [closed]

开发者 https://www.devze.com 2023-02-06 17:33 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

"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.

0

精彩评论

暂无评论...
验证码 换一张
取 消