---
title: "select(): IR builder function in typeshade/core/ir"
description: "select, an IR builder function in typeshade/core/ir. select: the free-function form of ReadonlyNode.select."
url: https://typeshade.dev/api/select/
language: en
---

# `select()`

Function in Builtins

select: the free-function form of ReadonlyNode.select.

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

This export returns an IR node. A `"use typeshade"` file calls the builtin itself: [`select()`](https://typeshade.dev/reference/functions/select/)

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```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>;
```

## Parameters

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

**`ifTrue` `number`**

**`ifFalse` `number`**

## Return value

`Node<'f32'>`

## Description

`select(cond, ifTrue, ifFalse)`: the free-function form of `ReadonlyNode.select`. Both branches must share a key; two JS numbers give an `f32` result.

## Targets

| Target | Support | Notes |
| --- | --- | --- |
| WGSL (WebGPU) | Supported | `select(a, b, c)`. |
| GLSL ES 3.00 (WebGL2) | Supported | `(c ? b : a)`. |
| CPU oracle | Not supported | The oracle has no implementation for it. |

## In the guide

- [Values and mutation](https://typeshade.dev/guide/internals/values-and-mutation/)
- [Control flow](https://typeshade.dev/guide/internals/control-flow/)

## See also

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

## Source

[`src/core/ir/node.ts`, line 1997](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L1997), at commit af54ddad5
