2011-07-25 24 views

回答

7

if [email protected]? && ['x','Y'].include?(@thread.name)

+0

謝謝,試過了,得到了一個語法錯誤,意想不到的tIVAR,期待keyword_then或';'或'\ n' – AnApprentice

+0

添加括號。他們在這種情況下需要 – Mchl

+1

非常好,謝謝! – AnApprentice

4

if @thread.present? and ['X', 'Y'].include?(@thread.name)

編輯:More info#present?

+0

什麼是目前所有有關? – AnApprentice

+0

一個對象存在,如果它不是空白或無 –

+0

可以用於一個領域? – AnApprentice

3
['x', 'Y'].include?(@thread.try(:name)) 

['x', 'Y'].include? @thread.try :name 
+0

讓我想哭......就像那本洋洋洋溢的書... – Mchl