Skip to content

Instantly share code, notes, and snippets.

@Harrisonl
Created November 24, 2016 09:33
Show Gist options
  • Save Harrisonl/0bdd299409e8ca8e0412572da4d5ac9e to your computer and use it in GitHub Desktop.
Save Harrisonl/0bdd299409e8ca8e0412572da4d5ac9e to your computer and use it in GitHub Desktop.
def strip_vowels(string, acc = "")
return acc if string.length <= 0
case string[0].downcase
when "a"
strip_vowels(string[1..-1], acc)
when "e"
strip_vowels(string[1..-1], acc)
when "i"
strip_vowels(string[1..-1], acc)
when "o"
strip_vowels(string[1..-1], acc)
when "u"
strip_vowels(string[1..-1], acc)
else
strip_vowels(string[1..-1], acc + string[0])
end
end
puts strip_vowels("harry")
#=> hrry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment