Question

Consider:

def first_login?
    if (self.sign_in_count <= 20)
        return true
    else
        return false
    end
end

It would be nice if I could just have it be 1 line of code...if possible.

Was it helpful?

Solution

def first_login?
    self.sign_in_count <= 20
end

Your comparison already returns boolean value

You don't need self as well because methods are invoked on self implicitly

OTHER TIPS

Exactly one line :)

def first_login?
   sign_in_count <= 20
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top