<ContentPage
  eyebrow="Runnable Examples"
  title="team_scoreboard"
  description="Structs, errors, lambdas, and loops in one file."
>
  <div className="grid gap-4 md:grid-cols-2">
    <KeyConceptCard title="What it demonstrates">
      <ul className="space-y-2">
        <li>Bundles structs, errors, lambdas, loops, and `catch` blocks in one file.</li>
        <li>Good reference for language features outside CLI tooling.</li>
      </ul>
    </KeyConceptCard>
  </div>

**Run it**

```bash
tea examples/full/team_scoreboard.tea
tea build examples/full/team_scoreboard.tea
./bin/team_scoreboard
```

**`team_scoreboard.tea`**

```tea
struct Team {
  name: String
  wins: Int
  losses: Int
}

error TeamError {
  NotFound(name: String)
}

const format_team = |team: Team| => `${team.name}: ${team.wins} wins / ${team.losses} losses`

const teams = [
  Team(name: "Ada", wins: 7, losses: 3),
  Team(name: "Grace", wins: 9, losses: 1),
  Team(name: "Linus", wins: 5, losses: 5)
]

@println("Team scoreboard")

var index = 0

while index < @len(teams)
  @println(format_team(teams[index]))
  index = index + 1
end

def find_team(name: String) -> Team ! TeamError.NotFound
  var idx = 0

  while idx < @len(teams)
    var candidate = teams[idx]

    if candidate.name == name
      return candidate
    end

    idx = idx + 1
  end

  throw TeamError.NotFound(name)
end
```

<div className="divider-section" />

  <NextSteps title="Related pages">
    <NextLink href="/docs/error-handling" title="Error Handling" description="Follow the typed error flow used here." />
    <NextLink href="/docs/structs" title="Structs" description="See the record types used in this example." />
  </NextSteps>
</ContentPage>
