使用or操作符時,My Ruby if語句失敗。爲什麼IF語句在OR ||時失敗用來?
<% if @body_id == 'plants' || 'trees' %>
<meta name="robots" content="noindex, nofollow">
<% end %>
使用or操作符時,My Ruby if語句失敗。爲什麼IF語句在OR ||時失敗用來?
<% if @body_id == 'plants' || 'trees' %>
<meta name="robots" content="noindex, nofollow">
<% end %>
你不能使用||
那樣,ID做['plants', 'trees'].includes? @body_id
代替。
'%w [植物樹]'所有冰雹rubocop –
@dezman - 謝謝! – traci123me
不是嗎?
<% if @body_id == 'plants' || @body_id == 'trees' %>
你是什麼意思與「失敗」,你會得到一個錯誤?如果是,請包括堆棧跟蹤。如果這是意外行爲,請添加您的實際和預期行爲。 – DarkCygnus