Last active
November 15, 2015 20:51
-
-
Save cris/01dcf82939902605364c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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