# Cairo Level 2: Data Structures

> Level 2: Data Structures of the LoWisa Cairo course: Structs and Enums, Pattern Matching, Collections. 3 lessons and 9 ideas, each explained in one line.

Data Structures is level 2 of 14 of the [LoWisa Cairo course](/courses/cairo/). It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

## Structs and Enums

- **Structs.** A **struct** groups named fields: instantiated by name, destructured by pattern.
- **Enums.** An **enum** declares variants that may carry data: Option and Result are enums like yours.
- **Generic types.** Types take **generic** parameters: Wallet<T>: checked at compile time.

## Pattern Matching

- **match exhaustively.** **match** handles every variant or fails to compile: the missing case is an error, forever.
- **Destructuring.** Patterns **destructure** structs and enums: fields bound as they match.
- **Options and results.** **Option** and Result are matched, mapped and propagated: absence and failure as values.

## Collections

- **Arrays.** A Cairo **array** is append-only: written once, read by index, the prover-friendly sequence.
- **Felt252Dict.** The **dictionary** type gives key-value storage in memory: squashed and verified at run’s end.
- **Spans.** A **span** is a read-only view over an array: passing data without copying it.

## Before and after this level

- **Before:** [Level 1: Cairo Foundations](/courses/cairo/level-1-cairo-foundations/): Values and Types, Functions, Control Flow.
- **Next:** [Level 3: Ownership & Memory](/courses/cairo/level-3-ownership-and-memory/): Cairo Memory Model, References and Snapshots, Designing Safe Data Flow.

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See [Checkpoints and flashcards](/help/checkpoints-and-flashcards/).

## Frequently asked questions

### What does Cairo Level 2: Data Structures cover?

Structs and Enums, Pattern Matching, Collections: 3 lessons and 9 ideas.

### What should I know before this level?

The level before it, Level 1: Cairo Foundations, which covers Values and Types, Functions, Control Flow.

## Learn Cairo on your phone

The first level is free. LoWisa is on Google Play and the App Store.

---

Source: https://lowisa.dev/courses/cairo/level-2-data-structures/ · Updated 2026-11-30
