Represents the use of the ‘unless` keyword, either in the block form or the modifier form.

bar unless foo
^^^^^^^^^^^^^^

unless foo then bar end
^^^^^^^^^^^^^^^^^^^^^^^
Attributes
Read

The condition to be evaluated for the unless expression. It can be any [non-void expression](github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).

unless cond then bar end
       ^^^^

bar unless cond
           ^^^^
Read

The body of statements that will executed if the unless condition is falsey. Will be ‘nil` if no body is provided.

unless cond then bar end
                 ^^^

The else clause of the unless expression, if present.

unless cond then bar else baz end
                     ^^^^^^^^
Class Methods

Initialize a new UnlessNode node.

Return a symbol representation of this node type. See ‘Node::type`.

Instance Methods

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.

def accept: (Visitor visitor) -> void

def child_nodes: () -> Array[nil | Node]

def comment_targets: () -> Array[Node | Location]

Returns the else clause of the unless node. This method is deprecated in favor of else_clause.

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?else_clause: ElseNode?, ?end_keyword_loc: Location?) -> UnlessNode

An alias for child_nodes

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, keyword_loc: Location, predicate: Prism::node, then_keyword_loc: Location?, statements: StatementsNode?, else_clause: ElseNode?, end_keyword_loc: Location? }

def end_keyword: () -> String?

The location of the ‘end` keyword, if present.

unless cond then bar end
                     ^^^

def inspect -> String

def keyword: () -> String

The location of the ‘unless` keyword.

unless cond then bar end
^^^^^^

bar unless cond
    ^^^^^^

Save the end_keyword_loc location using the given saved source so that it can be retrieved later.

Save the keyword_loc location using the given saved source so that it can be retrieved later.

Save the then_keyword_loc location using the given saved source so that it can be retrieved later.

def then_keyword: () -> String?

The location of the ‘then` keyword, if present.

unless cond then bar end
            ^^^^

Return a symbol representation of this node type. See ‘Node#type`.