Ruby: pm_if_node Struct Reference

Ruby 3.4.7p58 (2025-10-08 revision 7a5688e2a27668e48f8d6ff4af5b2208b98a2f5e)

Data Fields
pm_if_node Struct Reference

IfNode. More...

`#include <ast.h>`

## Data Fields
pm_node_t | base
| The embedded base node.
pm_location_t | if_keyword_loc
| IfNode#if_keyword_loc.
struct pm_node * | predicate
| IfNode#predicate.
pm_location_t | then_keyword_loc
| IfNode#then_keyword_loc.
struct pm_statements_node * | statements
| IfNode#statements.
struct pm_node * | subsequent
| IfNode#subsequent.
pm_location_t | end_keyword_loc
| IfNode#end_keyword_loc.
Data Fields inherited from pm_node
pm_node_type_t | type
| This represents the type of the node.
pm_node_flags_t | flags
| This represents any flags on the node.
uint32_t | node_id
| The unique identifier for this node, which is deterministic based on the source.
pm_location_t | location
| This is the location of the node in the source.

## Detailed Description

IfNode.

Represents the use of the if keyword, either in the block form or the modifier form, or a ternary expression.

    bar if foo
    ^^^^^^^^^^

    if foo then bar end
    ^^^^^^^^^^^^^^^^^^^

    foo ? bar : baz
    ^^^^^^^^^^^^^^^

Type: ::PM_IF_NODE

Definition at line 4496 of file ast.h.

## Field Documentation

## ◆ base

pm_node_t pm_if_node::base

The embedded base node.

Definition at line 4498 of file ast.h.

Referenced by pm_dump_json().

## ◆ end_keyword_loc

pm_location_t pm_if_node::end_keyword_loc

IfNode#end_keyword_loc.

The location of the end keyword if present, nil otherwise.

    if foo
      bar
    end
    ^^^

Definition at line 4587 of file ast.h.

Referenced by pm_dump_json().

## ◆ if_keyword_loc

pm_location_t pm_if_node::if_keyword_loc

IfNode#if_keyword_loc.

The location of the if keyword if present.

    bar if foo
        ^^

The if_keyword_loc field will be nil when the IfNode represents a ternary expression.

Definition at line 4511 of file ast.h.

Referenced by pm_dump_json().

## ◆ predicate

struct pm_node* pm_if_node::predicate

IfNode#predicate.

The node for the condition the IfNode is testing.

    if foo
       ^^^
      bar
    end

    bar if foo
           ^^^

    foo ? bar : baz
    ^^^

Definition at line 4529 of file ast.h.

Referenced by pm_dump_json(), pm_node_destroy(), and pm_visit_child_nodes().

## ◆ statements

struct pm_statements_node* pm_if_node::statements

IfNode#statements.

Represents the body of statements that will be executed when the predicate is evaluated as truthy. Will be nil when no body is provided.

    if foo
      bar
      ^^^
      baz
      ^^^
    end

Definition at line 4556 of file ast.h.

Referenced by pm_dump_json(), pm_node_destroy(), and pm_visit_child_nodes().

## ◆ subsequent

struct pm_node* pm_if_node::subsequent

IfNode#subsequent.

Represents an ElseNode or an IfNode when there is an else or an elsif in the if statement.

    if foo
      bar
    elsif baz
    ^^^^^^^^^
      qux
      ^^^
    end
    ^^^

    if foo then bar else baz end
                    ^^^^^^^^^^^^

Definition at line 4575 of file ast.h.

Referenced by pm_dump_json(), pm_node_destroy(), and pm_visit_child_nodes().

## ◆ then_keyword_loc

pm_location_t pm_if_node::then_keyword_loc

IfNode#then_keyword_loc.

The location of the then keyword (if present) or the ? in a ternary expression, nil otherwise.

    if foo then bar end
           ^^^^

    a ? b : c
      ^

Definition at line 4542 of file ast.h.

Referenced by pm_dump_json().

The documentation for this struct was generated from the following file:

- prism/ast.h