title: How do I conditionally delete strings from an array?
body: <p>I need to remove any strings from an array that are not of a certain length. The assignment recommends using <code>map</code> or <code>map!</code>. I have been playing with <code>map!</code>, <code>delete_if</code>, and <code>keep_if</code>, but I am getting nowhere. Can anyone help me? Below is one of my attempts:</p>
  
  <pre><code>dictionary = Array.new
  
  file = File.open("words.txt").each do | line |
      dictionary.push line
  end
  
  (wordlength = gets)
  wordlength = wordlength.to_i
  
  dictionary = dictionary.reject {|word| word.length != wordlength }
  
  puts dictionary
  </code></pre>