Created
July 28, 2023 08:43
-
-
Save robmiller/b7eaafc3ca99848f8681a2fb6407a34e to your computer and use it in GitHub Desktop.
Check if a string is a pangram in Ruby.
This file contains hidden or 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
class String | |
def pangram? | |
(("a".."z").to_a - self.downcase.chars.uniq).empty? | |
end | |
end | |
["The quick brown fox jumped over the lazy dogs!", "The slow dog didn't"].each do |text| | |
puts "#{text}: #{text.pangram?}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment