【发布时间】:2020-08-13 17:54:59
【问题描述】:
我有这个方法。
private fun getOffer(offers: OfferRepresentation, type: OfferType): ???? {
return when (type) {
OfferType.ADDON -> offers.addon
OfferType.SALE -> offers.sale
OfferType.PLAN -> offers.plan
OfferType.CUSTOMPLAN -> offers.customPlan
}
如何更改此方法以返回正确的类型?
【问题讨论】:
-
OfferRepresentation 类是什么样的?
-
@fejd OfferRepresentation 有四个属性 (offerTypes),可以是 addon、sale、plan 或 customPlan。如果 OfferRepresentation 有计划(或任何其他),则其他属性为空。