【发布时间】:2023-04-07 04:06:01
【问题描述】:
只想用三元表达式简化else语句,因为描述是代码中唯一的变化
if LaunchDarklyEnvironment.isPromoCodeAfterRegistrationForExistingUserEnabled() == true {
let descriptionCell = tableView.dequeueReusableCell(withIdentifier: ScoreCardStyledPrimaryTableViewCell.reuseID) as? ScoreCardStyledPrimaryTableViewCell
descriptionCell?.configure(withTitle: "promo_code_after_registration_description_header".localized, description: "promo_code_after_registration_description_short".localized)
cell = descriptionCell
} else{
let descriptionCell = tableView.dequeueReusableCell(withIdentifier: ScoreCardStyledPrimaryTableViewCell.reuseID) as? ScoreCardStyledPrimaryTableViewCell
descriptionCell?.configure(withTitle: "promo_code_after_registration_description_header".localized, description: "promo_code_after_registration_description".localized)
cell = descriptionCell
}
【问题讨论】:
标签: swift conditional-operator