+ 1

Does the operator <> exist?

In school I learned to use <> and not !=. I know != from my Java classes, so I have no problem using that, but I was wondering if <> might be outdated for example

30th Mar 2018, 2:41 AM
ArcZeroes
ArcZeroes - avatar
3 Antworten
+ 7
There are 9+ listed here for that inequality style (includes spreadsheets, SQL, Pascal, etc): https://en.m.wikipedia.org/wiki/Relational_operator#Standard_relational_operators The chart shows variants for other languages and additional comparison operators.
30th Mar 2018, 3:04 AM
Kirk Schafer
Kirk Schafer - avatar
+ 6
Jay Matthews I was going to joke switching "or" to "and" and posting "what's wrong with my code" but it turns out: https://rosettacode.org/wiki/Operator_precedence#Pascal both "or" and "and" are more tightly bound than the comparisons, and I think you get : x < (y or x) > y ...which is still amusing to consider debugging (if I'm reading that right).
30th Mar 2018, 3:44 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Just for clarification, there is an operator like that in Java, the diamond operator, but it is not used for logical comparisons. Instead, it is used to initialize generic classes in a more streamlined fashion. Instead of: HashMap<String, Integer> map = new HashMap<String, Integer>(); you can simply type: HashMap<String, Integer> map = new HashMap<>(); Notice the diamond "<>" in the second example. That is actually an operator. Java 10 also adds a "var" keyword for type inference, so the above example will look like: var map = new HashMap<String, Integer>(); which is still shorter than the above. Even though this isn't all too related to the original question, it's very useful and practical knowledge to have.
30th Mar 2018, 3:43 AM
LunarCoffee
LunarCoffee - avatar