Truthiness
suggest changeRemarks
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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents