class SyntaxTree::MAssign
first, = value
destructuring behavior that you can achieve with the following:
Both sides support splats, as well as variables following them. There’s also
value = first, second, third
as well as splitting out variables on the right, as in:
first, second, third = value
splitting out variables on the left like:
MAssign is a parent node of any kind of multiple assignment. This includes
def ===(other)
def ===(other) other.is_a?(MAssign) && target === other.target && value === other.value end
def accept(visitor)
def accept(visitor) visitor.visit_massign(self) end
def child_nodes
def child_nodes [target, value] end
def copy(target: nil, value: nil, location: nil)
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
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { target: target, value: value, location: location, comments: comments } end
def format(q)
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
def initialize(target:, value:, location:)
def initialize(target:, value:, location:) @target = target @value = value @location = location @comments = [] end