"Difference" comparator in Expression Builder

Matt Jensen shared this question 5 years ago
Answered

Hi there


I am builder some expressions in the Expression Builder.


I am using textual strings of 'true' and 'false' to do some conditional logic.


Can someone please tell me how exactly the 'Difference' Comparator works?


Most importantly, Is it the exact opposite to the 'Equals' comparator? Or in pseudo code, does it mean 'Not Equal To', or is the label on it correct, meaning 'Different To'?


No big deal but I can't find anything that explains it exactly.


Cheers


Matt

Comments (5)

photo
1

It's exactly the opposite of the 'Equals' comparator. In the end all values are turned into strings in the expressions. So the comparators compare 'strings'.

photo
1

Great, thanks Victor.


I would argue it should be re-labeld 'Does Not Equal' or similar then, for clarity. 'Difference' is not intuitive to me.


Anyway, thanks


Cheers


Matt

photo
1

Mmm, that's interesting. You know, we are not English native speakers so I'm afraid we don't get the semantic difference between those two terms. Would you mind to tell us what's the difference please?

photo
1

Sure thing Victor


To me though it's probably more of a 'consistency with programming terminology' than a semantic issue.


I think all programming languages refer to the opposite of 'Equals' as 'Not Equal To'. For example:


- PHP http://php.net/manual/en/language.ope...


- C# http://msdn.microsoft.com/en-us/libra... (Equality Operators section)


- Javascript http://www.w3schools.com/js/js_compar...


I'm sure you guys are familar with all that though.


As for semantics:


- 'Not Equal to' is the exact opposite of 'Equal to', by definition of the word 'not'.


- "Difference". If you were to ask the question, "What is the difference between 'a' and 'b'?" - asking such a question implies there you think that there are some things similar between 'a' and 'b', but also some things not the same.


In the case of strings, the 'difference' between say the strings 'test' and 'testing' would be, in my view, the letters 'ing'.


However, in the case of boolean comparisons, I can understand why you may have labelled it 'difference' though - if it's not 'equal' to 'true', then anything that is "different" to 'true' must be false.


Therefore, in my view, if the 'difference' operator actually means exactly the opposite of 'equals', then it must be labelled 'not equal'.


So I think it would be much clearer to users to call it 'Not Equal (To)', if it's the opposite of 'Equal'.


Hope that helps...!


Cheers


Matt

photo
1

It does! Will do, thanks!