In Erlang, using => to compare two variables results in a syntax error, you have to use >= instead:
1> 10 => 5.
* 1: syntax error before: '>'
2> 10 >= 5.
true
Why is that? The same applies for <= which has to be written as =<. Is this because Erlang always used this syntax, or are the sequences => and >= used somewhere else?
This is probably just an Erlang convention. The reason I’d guess would be to do with how we pronounce these symbols: “greater than or equal to”, “less than or equal to”. It’s really a rendering of the greater-than-or-equal-to/less-than-or-equal-to symbol in ASCII, so at some point someone decided the token should be
<=and>=, and the convention has stuck in most languages, but it’s fairly arbitrary. Perhaps they were attempting to create some kind of representation of the asymmetric nature of these operators.It’s also worth noting that lots of languages use
=>to mean some kind of arrow, such as separating the body of a function from its arguments, or as logical entailment. Not sure about the converse one.EDIT: It appears that Erlang uses
<=in comprehensions, which is why they’ve avoided using it as a comparison operator, and opted for the (slightly backwards) syntax instead.