==
and eq
give the same result using EL to do my string comparison tests:
<c:if test="${person.sokande_i == 'endast_usa'}">Endast USA</c:if>
<c:if test="${person.sokande_i == 'alla'}">Alla länder</c:if>
<c:if test="${person.sokande_i == 'alla_utom_usa'}">Alla utom USA</c:if>
Should I use eq
instead? Is ==
for integers only? But it works also for strings. AFAIK ==
test whether hashCodes are equal and eq
means "meaningfully different".
Another question says ==
and eq
do the same thing.
Is there no difference here? IS not the difference the one I'm stating: ==
looks at the hashCode and eq
looks at the implementation of equals(...)
.
Both are same. Both
==
andeq
will result in the following code:for EL
They're both the same. I use
eq
in EL as it is more readable like a sentence.According to documentation, it's the same thing
One difference though : string operators like
eq, ne, lt, gt, ge, le
exist as they are XML safe, they would not need to be escaped like<=
for instance.It's explained here