Slide 28
Slide 28 text
ARRAY PATTERN
• An array pattern with
RubyVM::AbstractSyntaxTree::Node
class RubyVM::AbstractSyntaxTree::Node
def deconstruct
[type, *children, [first_lineno, first_column, last_lineno, last_column]]
end
end
ast = RubyVM::AbstractSyntaxTree.parse('1 + 1')
p ast.type #=> :SCOPE
p ast.children #=> [[], nil, #]
p ast.deconstruct #=> [:SCOPE, [], nil,
#, [1, 0, 1, 5]]