Skip to content

Instantly share code, notes, and snippets.

@cris
Last active November 15, 2015 20:51
Show Gist options
  • Save cris/01dcf82939902605364c to your computer and use it in GitHub Desktop.
Save cris/01dcf82939902605364c to your computer and use it in GitHub Desktop.
require 'set'
# Remove vowels from string
# Hash-solution with Ruby 2.3
vowels = {'a' => true, 'e' => true, 'i' => true, 'o' => true, 'u' => true}
"cool test".chars.reject(&vowels).join #=> "cl tst"
# Set-solution could be in Ruby 2.3 :)
vowels = Set.new(%w[a e i o u])
"cool test".chars.reject(&vowels).join #=> "cl tst"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment