On this page
Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
Prism::LocalVariableWriteNode
Represents writing to a local variable.
foo = 1 ^^^^^^^
Class methods 2
Instance methods 15
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](github.com/ruby/prism/blob/main/docs/local_variable_depth.md).
The name of the local variable, which is an [identifier](github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
foo = :bar # name `:foo` abc = 123 # name `:abc`
The value to write to the local variable. It can be any [non-void expression](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