Class Nodes.LocalVariableWriteNode

java.lang.Object
org.prism.Nodes.Node
org.prism.Nodes.LocalVariableWriteNode
Enclosing class:
Nodes

public static final class Nodes.LocalVariableWriteNode extends Nodes.Node
 Represents writing to a local variable.

     foo = 1
     ^^^^^^^
 
  • Field Details

    • name

      public final org.jruby.RubySymbol name
       The name of the local variable, which is an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
      
           foo = :bar # name `:foo`
      
           abc = 123  # name `:abc`
       
    • depth

      public final int depth
       The number of semantic scopes we have to traverse to find the declaration of this variable.
      
           foo = 1         # depth 0
      
           tap { foo = 1 } # depth 1
      
       The specific rules for calculating the depth may differ from individual Ruby implementations, as they are not specified by the language. For more information, see [the Prism documentation](https://github.com/ruby/prism/blob/main/docs/local_variable_depth.md).
       
    • value

      public final Nodes.Node value
       The value to write to the local variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
      
           foo = :bar
                 ^^^^
      
           abc = 1234
                 ^^^^
      
       Note that since the name of a local variable is known before the value is parsed, it is valid for a local variable to appear within the value of its own write.
      
           foo = foo
       
  • Constructor Details

    • LocalVariableWriteNode

      public LocalVariableWriteNode(int startOffset, int length, org.jruby.RubySymbol name, int depth, Nodes.Node value)
  • Method Details