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, = valueAttributes
Node
the value being assigned
def initialize(target:, value:, location:) @target = target @value = value @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(MAssign) && target === other.target && value === other.value endSource
def accept(visitor) visitor.visit_massign(self) endSource
def child_nodes [target, value] endSource
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 endSource
def deconstruct_keys(_keys) { target: target, value: value, location: location, comments: comments } endSource
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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4