如题,在restful_authentication这个gems中看到这么一段,搞不懂这里的这个双叹号是啥意思,
[code="ruby"] def logged_in?
!!current_user
end
# Accesses the current user from the session.
# Future calls avoid the database because nil is not equal to false.
def current_user
@current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie) unless @current_user == false
end
[/code]
哪位能给解释下么,谢谢 :D
[b]问题补充:[/b]
如果就是两个 否 , 为何不直接用
def logged_in?
!!current_user
end
呢?
[b]问题补充:[/b]
如果就是两个 否 , 为何不直接用
def logged_in?
current_user
end
呢?
[b]问题补充:[/b]
哦,明白了!
这里loggged_in?要求返回的是boolean,不能是object
谢谢