lib/linefit.rb
############################################################################
# Verify that the input weights are numeric
#
Verify that the input weights are numeric
Verify that the input weights are numeric
def validWeights(weights)
      0.upto(weights.length) do |i|
         unless weights[i]
            puts "Input weights[#{i}] is not defined" unless @hush
            return false
         end
         if weights[i] !~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/
            puts "Input weights[#{i}] is not a number: #{weights[i]}" unless @hush
            return false
         end
      end
      return true
   end
def validWeights ( weights ) 0 . upto ( weights . length ) do | i | unless weights [ i ] puts "Input weights[#{i}] is not defined" unless @hush return false end if weights [ i ] !~ / ^([+-]?)(?= \d | \. \d ) \d *( \. \d *)?([Ee]([+-]? \d +))?$ / puts "Input weights[#{i}] is not a number: #{weights[i]}" unless @hush return false end end return true end
Verify that the input weights are numeric
Verify that the input weights are numeric
weights
<not_specific>