title: Counting and computing the average length of words in ruby
body: <p>I'm trying to debug a program in ruby that is meant to compute and print the average length of words in an array.</p>
  
  <pre><code>words = ['Four', 'score', 'and', 'seven', 'years', 'ago', 'our', 'fathers', 'brought', 'forth', 'on', 'this', 'continent', 'a', 'new', 'nation', 'conceived', 'in', 'Liberty', 'and', 'dedicated', 'to', 'the', 'proposition', 'that', 'all', 'men', 'are', 'created', 'equal']
  
  word_lengths = Array.new
  
  words.each do |word|
  
    word_lengths &lt;&lt; word_to.s
  
  end
  
  sum = 0
  word_lengths.each do |word_length|
    sum += word_length
  end
  average = sum.to_s/length.size
  puts "The average is " + average.to_s
  </code></pre>
  
  <p>Obviously, the code is not working. When I run the program, I receive an error message that says the string '+' can't be coerced into fixnum (typeerror).</p>
  
  <p>What do I do no make the code compute the average length of the strings in the array?</p>