使用 !在红宝石
问题描述:
谁能解释一下下面ruby例子中!
的用法:
Can some one please explain the usage !
in the following ruby example:
def show
@article = Article.find(params[:id])
respond_to do |format|
format.html { render :layout => ! request.xhr? }
end
end
谢谢
答
这只是合乎逻辑的not
.
request.xhr?
=> true
!request.xhr?
=> false