I'm just curious if there are any programming languages that use the '=>' and '=<' operators for something.

I wonder why these are not commonly used when their variant '<=' and '>=' are so widely used by most languages.

Is there a reason why?

EDIT: I'm not asking why they aren't used for the same task as '<=', but why the operators go unused for anything.

  • 5
    My guess is that it is because you say "less or equal than" in English, so it is more natural to write the corrisponding symbols on the keyboard. – Виталий Олегович Aug 20 '13 at 13:07
  • because that would be confusing, it is easier to have only 1 variant than have to do a coinflip each time you need one – ratchet freak Aug 20 '13 at 13:08
  • 2
    I use => all the time when doing .net stuff... but I do not think it means what you think it means – Drake Clarris Aug 20 '13 at 13:10
  • 3
    @DrakeClarris that's inconceivable. – Reactgular Aug 20 '13 at 13:17
  • 1
    Haskell uses => for type class constraints. Though that's probably not an "operator" ;) – Andres F. Aug 20 '13 at 13:24

About =>

C# does. Look here: http://msdn.microsoft.com/en-us/library/bb311046.aspx

As MichaelT commented, it is used as a Fat comma. From Wikipedia:

It is primarily associated with PHP, Ruby and Perl programming languages, which use it to declare hashes. Using a fat comma to bind key-value pairs in a hash, instead of using a comma, is considered an example of good idiomatic Perl. In CoffeeScript, the fat comma is used to declare a function that is bound to this.

PHP: http://php.net/manual/en/language.types.array.php

Rails: https://stackoverflow.com/questions/969900/ruby-on-rails-what-does-the-symbol-mean

About =<

Prolog uses it as a comparison operator http://www.cse.unsw.edu.au/~billw/prologdict.html#comparison

| improve this answer | |
  • @MathewFoscarini both symbols are used in programming languages. Take a look at my modified answer. – Виталий Олегович Aug 20 '13 at 13:23
  • 1
    The php and ruby use of => likely comes from the perl fat comma – user40980 Aug 20 '13 at 13:55
  • @MichaelT thank you! I have modified my answer adding infos about fat comma. – Виталий Олегович Aug 20 '13 at 14:35

C# (and others) use => as a function declaration token.

The alternatives are used because when spoken it's always "Less than or Equal to" or "Greater than or Equal to" not "Equal to or...".

| improve this answer | |
  • oh right, ()=>{....} it's hard to remember that when you look just as the operator => – Reactgular Aug 20 '13 at 13:11
  • and after C#, coffeescript, and then ES6/Harmony had picked fat arrow syntax. – c69 Aug 20 '13 at 19:45

Scala and ML use => in pattern matching.

Scala Example :

x match {
  case 1 => "one"
  case 2 => "two"
  case _ => "many"

ML Example:

case shape
of Circle (_, r) => 3.14 * r * r
 | Square (_, s) => s * s
 | Triangle (a, b, c) => heron (a, b, c)

Haskell uses it for class constraints :

(Eq a) => a -> a -> Bool  -- type a should be a member of the Eq typeclass
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.