---
title: "select(): typeshade/core/ir의 IR 빌더 함수, TypeShade 컴파일러 API"
description: "select, typeshade/core/ir의 IR 빌더 함수입니다. select: ReadonlyNode.select의 독립 함수 버전입니다."
url: https://typeshade.dev/ko/api/select/
language: ko
---

# `select()`

함수, 내장 함수 분류

select: ReadonlyNode.select의 독립 함수 버전입니다.

`import { select } from 'typeshade/core/ir'`

이 export는 IR 노드를 반환합니다. `"use typeshade"` 파일에서는 내장 함수 자체를 부릅니다: [`select()`](https://typeshade.dev/ko/reference/functions/select/)

설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.

## 구문

```ts
function select(cond: ReadonlyNode<'bool'>, ifTrue: number, ifFalse: number): Node<'f32'>;
function select<R extends string>(
  cond: ReadonlyNode<'bool'>,
  ifTrue: ReadonlyNode<R> | number,
  ifFalse: ReadonlyNode<R> | number,
): Node<R>;
```

## 매개변수

**`cond` `ReadonlyNode<'bool'>`**

**`ifTrue` `number`**

**`ifFalse` `number`**

## 반환값

`Node<'f32'>`

## 설명

`select(cond, ifTrue, ifFalse)`는 `ReadonlyNode.select`의 독립 함수 버전입니다. 두 분기는 같은 키를 가져야 합니다. JS 숫자 두 개를 넘기면 결과는 `f32`입니다.

## 대상별 지원

| 대상 | 지원 | 비고 |
| --- | --- | --- |
| WGSL (WebGPU) | 지원 | `select(a, b, c)`로 생성합니다. |
| GLSL ES 3.00 (WebGL2) | 지원 | `(c ? b : a)`로 생성합니다. |
| CPU 오라클 | 지원 안 함 | 오라클에는 이 함수의 구현이 없습니다. |

## 관련 가이드

- [값과 변경](https://typeshade.dev/ko/guide/internals/values-and-mutation/)
- [제어 흐름](https://typeshade.dev/ko/guide/internals/control-flow/)

## 함께 보기

- [`select()`](https://typeshade.dev/ko/reference/functions/select/)

## 소스

[`src/core/ir/node.ts`, 1997행](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L1997), 커밋 af54ddad5 기준
