5.9. Wildcard Pattern

The wildcard pattern matches any value and binds no variables.

5.9.1. Syntax

[36]WildcardPattern::= _  

5.9.2. Type

A wildcard pattern matches any type. The matching produces an empty typing context.

5.9.3. Examples

Wildcard Assignments
{- Showcase various wildcard assignments -}

val (_,(_,x),_) = (0,(2,2),[5,5,5])
val [[_,y],[_,z]] = [[1,3],[2,4]]

[x, y, z]

{-
OUTPUT:
[2, 3, 4]
-}
Implication by Fewer Cases
{-
  Defining logical implication by cases, 
  using wildcard to abbreviate the 'true' cases. 
-}

def implies(true, false) = false
def implies(_, _) = true

implies(true, true)

{-
OUTPUT:
true
-}

5.9.4. Related Links

Related Reference Topics

Related Tutorial Sections