0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Ruby】条件分岐で得られる結果を変数に代入して引数に入れ込みたい時

Posted at

Before

    if planner_admins.any? {|planner_admin| planner_admin.ad?}
      admins = [Admin.get_invoice_viewer]
    else
      admins = planner_admins
    end
    SlackNoticeService.notice_invoice_viewer(@confirm, sponsor, admins)

After


    admins = if planner_admins.any? {|planner_admin| planner_admin.ad?}
               [Admin.get_invoice_viewer]
             else
               planner_admins
             end
    SlackNoticeService.notice_invoice_viewer(@confirm, sponsor, admins)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?