Skip to content

Instantly share code, notes, and snippets.

@robmiller
Created July 28, 2023 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robmiller/b7eaafc3ca99848f8681a2fb6407a34e to your computer and use it in GitHub Desktop.
Save robmiller/b7eaafc3ca99848f8681a2fb6407a34e to your computer and use it in GitHub Desktop.
Check if a string is a pangram in Ruby.
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