lib/unparser/ast/local_variable_scope.rb
def first_assignment_in_body_and_used_in_condition?(body, condition)
        condition_reads = AST.local_variable_reads(condition)

        candidates = AST.local_variable_assignments(body).select do |node|
          name = node.children.first
          condition_reads.include?(name)
        end

        candidates.any? do |node|
          first_assignment?(node)
        end
      end
# Test if local variables where first assigned in body and read by conditional
#
# @param [Parser::AST::Node] body
# @param [Parser::AST::Node] condition
#
# @api private
#
Test if local variables where first assigned in body and read by conditional
Test if local variables where first assigned in body and read by conditional
def first_assignment_in_body_and_used_in_condition?(body, condition)
        condition_reads = AST.local_variable_reads(condition)
        candidates = AST.local_variable_assignments(body).select do |node|
          name = node.children.first
          condition_reads.include?(name)
        end
        candidates.any? do |node|
          first_assignment?(node)
        end
      end
def first_assignment_in_body_and_used_in_condition? ( body , condition ) condition_reads = AST . local_variable_reads ( condition ) candidates = AST . local_variable_assignments ( body ) . select do | node | name = node . children . first condition_reads . include? ( name ) end candidates . any? do | node | first_assignment? ( node ) end end
Test if local variables where first assigned in body and read by conditional
Test if local variables where first assigned in body and read by conditional
body
condition
None
api
None