What do you think of the way ruby is written?

when I first got in touch with ruby, I saw that my colleague had this code when I was in review today:

provider = campaign_type == :entry ? Settings.pay_method_to_provider[pay_method] : self.auth_provider

it"s hard to understand at first glance.
what do you think?

Mar.18,2021

in general, when using the ternary operator, if the statement is long, you can write:

provider = if campaign_type == :entry
             Settings.pay_method_to_provider[pay_method]
           else 
             self.auth_provider
           end

but there are a lot of such one-line streams in Ruby code, so just get used to it.

Menu