Truthiness

suggest change

Remarks

As a rule of thumb, avoid using double-negations in code. Rubocop says that double negations are unnecessarily complex and can often be replaced with something more readable.

!!user is false for both nil and false. !user.nil? is false only for nil, so it treats false as present. Use the nil? form only when that is what you mean:

def user_exists?
    !user.nil?
end

!!user is the check that rejects both nil and false:

def user_exists?
    !!user
end

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents