class SyntaxTree::MAssign
MAssign
is a parent node of any kind of multiple assignment. This includes splitting out variables on the left like:
first, second, third = value
as well as splitting out variables on the right, as in:
value = first, second, third
Both sides support splats, as well as variables following them. There’s also destructuring behavior that you can achieve with the following:
first, = value
Attributes
value[R]
Node
-
the value being assigned
Public Class Methods
new(target:, value:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 7510 def initialize(target:, value:, location:) @target = target @value = value @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 7554 def ===(other) other.is_a?(MAssign) && target === other.target && value === other.value end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 7517 def accept(visitor) visitor.visit_massign(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 7521 def child_nodes [target, value] end
Also aliased as: deconstruct
copy(target: nil, value: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 7525 def copy(target: nil, value: nil, location: nil) node = MAssign.new( target: target || self.target, value: value || self.value, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 7539 def deconstruct_keys(_keys) { target: target, value: value, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 7543 def format(q) q.group do q.group { q.format(target) } q.text(" =") q.indent do q.breakable_space q.format(value) end end end