When I first came into contact with ruby, I saw my colleagues have this code when reviewing today:
provider = campaign_type == :entry ? Settings.pay_method_to_provider[pay_method] : self.auth_provider
It’s really hard to understand at a glance. . .
What do you think?
In general, when using the boolean-exp character, if the statement is longer, it can be written as follows:
provider = if campaign_type == :entry Settings.pay_method_to_provider[pay_method] else self.auth_provider end
However, Ruby code does have a lot of such one-line flow, so it is good to get used to it.