4

What does the !! mean in this Ruby function?

def is_i?
   !!(self =~ /^[-+]?[0-9]+$/)
end
SyntaxGoonoo
  • 900
  • 8
  • 10

1 Answers1

5

It makes sure the response is a boolean. So nil or false wil become false, any other value becomes true

zaius
  • 6,409
  • 4
  • 28
  • 50