Skip to content
On this page
class · Ruby 4.0

Prism::IfNode

< Prism::Node 20 instance methods 2 class methods

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
^^^^^^^^^^^^^^^

Class methods 2

Instance methods 20

Attributes
Read

The node for the condition the IfNode is testing.

if foo
   ^^^
  bar
end

bar if foo
       ^^^

foo ? bar : baz
^^^
Read

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
Read

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
                ^^^^^^^^^^^^