2 added 125 characters in body
source | link

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

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)

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
1
source | link

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)