Implement String#digit?
(in Java StringUtils.isDigit(String)
), which should return true
if given object is a
digit (0-9), false
otherwise.
class String
def digit?
# your code goes here
end
end
class String
def digit?
self.match?(/\A\d\z/)
end
end
class String
def digit?
/\A\d\z/ === self
end
end