title: Removing vowels from string in Ruby
body: <p>I am testing possible solutions for the following problem. The first two solutions I came up with 'disembowel' &amp; 'disembowel_2' aren't running properly. I'm looking to figure out why.</p>
  
  <p>Disembowel_3 is by far my favorite solution. But I feel like I have no right to use disembowel_3 if I don't understand where I went wrong with my first two solutions.</p>
  
  <p>Could anyone help me figure out what's wrong with the first two solutions?</p>
  
  <pre><code># Write a function disemvowel(string), which takes in a string,
  # and returns that string with all the vowels removed. Treat "y" as a
  # consonant.
  
  def disemvowel(string)
    string_array = string.split
    vowels = %w[aeiou]
    i = 0
    while i &lt; string.length
      if vowels.include? string[i] == true
        string_array[i] =  " "
      end
      i +=1
    end
  
    new_string = string_array.join
    new_string = new_string.sub(/\s+/,"")
    return new_string
  end
  
  
  def disemvowel_2(string)
    string_array = string.split('')
    string_array.delete('a','e','i','o','u')
    return string_array.join('')
  end
  
  # This is my favorite solution.
  def disemvowel_3(string)
    result = string.gsub(/[aeiou]/i, '')
    return result
  end
  
  
  #tests
  puts disemvowel("foobar") 
  puts disemvowel("ruby") 
  puts disemvowel("aeiou") 
  </code></pre>