lib/opal/nodes/masgn.rb in opal-0.11.4 vs lib/opal/nodes/masgn.rb in opal-1.0.0.beta1

- old
+ new

@@ -1,12 +1,13 @@ # frozen_string_literal: true + require 'opal/nodes/base' module Opal module Nodes class MassAssignNode < Base - SIMPLE_ASSIGNMENT = [:lvasgn, :ivasgn, :lvar, :gvasgn, :cdecl, :casgn] + SIMPLE_ASSIGNMENT = %i[lvasgn ivasgn lvar gvasgn cdecl casgn].freeze handle :masgn children :lhs, :rhs def compile @@ -77,14 +78,15 @@ end end end def compile_assignment(child, array, idx, len = nil) - if !len || idx >= len - assign = s(:js_tmp, "(#{array}[#{idx}] == null ? nil : #{array}[#{idx}])") - else - assign = s(:js_tmp, "#{array}[#{idx}]") - end + assign = + if !len || idx >= len + s(:js_tmp, "(#{array}[#{idx}] == null ? nil : #{array}[#{idx}])") + else + s(:js_tmp, "#{array}[#{idx}]") + end part = child.updated if SIMPLE_ASSIGNMENT.include?(child.type) part = part.updated(nil, part.children + [assign]) elsif child.type == :send