哪些更好的Ruby代碼格式化風格,爲什麼?Ruby'if'塊爲變量賦值的推薦縮進樣式?
選項A:
def load_business
@business ||= if params[:badge_uuid]
# some code
else
# some other code
end
end
選項B:
def load_business
@business ||= if params[:badge_uuid]
# some code
else
# some other code
end
end
我寧願避免他們兩個。也許爲這兩種情況創建方法並使用':'然後呢? – 2012-01-05 15:49:22
我將整個if語句拆分爲一個方法。@ business || = business_value(params)。 – Darryl 2012-01-05 15:51:44
我不明白爲什麼問題已經結束,這似乎是一個有效的問題......風格問題與編程非常相關。 – tokland 2012-01-05 17:15:26