これを Ruby でもっとエレガントに書く方法はありますか?
def tutorial_completed?
people.any? && projects.any? && invoices.any?
end
これを Ruby でもっとエレガントに書く方法はありますか?
def tutorial_completed?
people.any? && projects.any? && invoices.any?
end
def tutorial_completed?
[people, projects, invoices].all?(&:any?)
end
私は以下のようにします:
[people,projects,invoices].all? {|i| i.any? }
デモ
people = [true]
projects = [false]
invoices = [true,12]
[people,projects,invoices].all? {|i| i.any? }
# => false