// SPDX-License-Identifier: CC-BY-SA-4.0
// SPDX-FileCopyrightText: 2024-2026 hyperpolymath (Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>)
= Lesson 4: Pattern Matching

Destructure data with match expressions:

[source,affinescript]
----
fn describe(x: Int) -> String {
  return match x {
    0 => "zero",
    1 => "one",
    _ => "many",
  };
}
----

== Tuple Patterns

[source,affinescript]
----
fn first(pair: (Int, Int)) -> Int {
  return match pair {
    (a, b) => a,
  };
}
----

Next: link:lesson-05-types.adoc[Lesson 5: Types and Inference]
