What is the difference between using "logic:equal" and "logic:notEqual" tags?
For example, I c开发者_如何学Goan have a code like:
<logic:equal name="userForm" property="isRishi" value="YES">
Welcome, your name is Rishi</logic:equal>
And another code like this:
<logic:notEqual name="userForm" property="isRishi" value="NO">
Welcome, your name is Rishi</logic:notEqual>
Both would function the same. So what difference is there in using these two tags?
If there are only two possible values, the only difference is that the second form is harder to understand due to the double negation.
If isRishi
can have values other than "YES" and "NO" (e.g. null) then the difference should be obvious.
They exist for better readability. notEqual to no
is convoluted and harder to grasp.
And also, for the same reason why the !
operator exists.
There is also the else-case. What if you want to do one thing in the "YES" case and one in the not-YES case? You could phrase the other case as equal to NO, but (a) it might be null and (b) if you dont have boolean but something else there might be many values you are not interested in.
精彩评论