In Ruby, only false
and nil
are falsey; everything else is truthy. You can use two not
operators to check an object's truthiness:
!!false # false
!!nil # false
!![] # true
!!{} # true
!!'' # true
!!0 # true
But then I found that empty-regex literal //
is falsey, but as a variable, it's truthy!:
!!// # false!
not not // # false
x = //
x.class # Regex
!!x # true
I think this is a quirk of the parser. How can I ask the parser what it's doing?