Skip to content

Latest commit

 

History

History
47 lines (39 loc) · 857 Bytes

is_the_string_uppercase.md

File metadata and controls

47 lines (39 loc) · 857 Bytes

Description

Is the string uppercase?

Task

Create a method to see whether the string is ALL CAPS.

Examples (input -> output)

"c" -> False
"C" -> True
"hello I AM DONALD" -> False
"HELLO I AM DONALD" -> True
"ACSKLDFJSgSKLDFJSKLDFJ" -> False
"ACSKLDFJSGSKLDFJSKLDFJ" -> True

In this Kata, a string is said to be in ALL CAPS whenever it does not contain any lowercase letter so any string containing no letters at all is trivially considered to be in ALL CAPS.

class String
  def is_upcase?
    # TODO: Program me
  end
end

My Solution

class String
  def is_upcase?
    self == self.upcase
  end
end

Better/Alternative solution from Codewars

class String
  def is_upcase?
    self == upcase
  end
end