ある値に、[[ユニオン型 (TypeScript)|ユニオン型]]などを条件分岐して算出した値を代入するケース。
```ts
import { match } from "ts-pattern";
type Animal = "dog" | "cat" | "owl";
const getAnimal = (): Animal => {
const animals: Animal[] = ["dog", "cat", "owl"];
return animals[Math.floor(Math.random() * animals.length)]!;
};
const japaneseName = match(getAnimal())
.with("dog", () => "犬")
.with("cat", () => "猫")
.with("owl", () => "フクロウ")
.exhaustive();
```