---
title: "if · RUAL Documentation"
description: "Conditional branching for arrays (if.. then.. else..)."
canonical: https://docs.rual.nl/block-types/array/array_branch
language: en
---

# if

This block is part of the [`array`](https://docs.rual.nl/block-types/array) group and was last modified in core [`v10.4.28`](https://docs.rual.nl/core-versions/100428).

Conditional branching for arrays (if.. then.. else..).

- true required `array` Input pin for the "true" branch array.

- false required `array` Input pin for the "false" branch array.

- boolean required `condition` Input pin for the boolean condition.

- array `array` Output pin for the resulting array based on the condition.

Selects between the two array inputs: outputs the then input when the condition pin resolves to strict boolean true, otherwise the else input. Any non-true value (including truthy non-booleans) falls to else. If the selected input is not an array, outputs an empty array.

| `branch` |
| --- |
| `condition` |

A typical wiring for [if](https://docs.rual.nl/block-types/array/array_branch): [search](https://docs.rual.nl/block-types/storage/function_search) feeds the `then` pin; [remove duplicates](https://docs.rual.nl/block-types/array/array_remove_duplicates) feeds the `else` pin; [==](https://docs.rual.nl/block-types/condition/condition_equal) feeds the `condition` pin; the `array` out pin feeds [length](https://docs.rual.nl/block-types/array/array_length).

![Studio canvas example for the if block: typical wiring for if.](https://docs.rual.nl/canvas-examples/array_branch.png)

### Commonly used with

In production blueprints, this block is most often wired together with:

- [search](https://docs.rual.nl/block-types/storage/function_search): feeds into this block. searches in the given storage based on a query.

- [remove duplicates](https://docs.rual.nl/block-types/array/array_remove_duplicates): feeds into this block. Removes duplicate values from an array.

- [==](https://docs.rual.nl/block-types/condition/condition_equal): feeds into this block. returns true if the two values are equal.

- [set fields](https://docs.rual.nl/block-types/mutations/mutations_set_bp_field_multiple): this block feeds into it. Generates an array of mutations based on the given filled fields.

- [new object](https://docs.rual.nl/block-types/object/object_new_fields): this block feeds into it. Builds a new object filled with the given fields.

- [select field values](https://docs.rual.nl/block-types/array/array_get_values_from_bp_field): feeds into this block. returns an array with values of the given field in this array of objects.

### Version history

Introduced in [`v10.4.28`](https://docs.rual.nl/core-versions/100428).
