I liked the approach of builders for solving complex logic and specifically the block-based builder design.

I have a single concern that if for simple data models we are using builders, which essentially is an additional component, can’t we have the same flexibility with structs and a default value nil for optionals.

struct OptionDetailDataStruct: Equatable {let isExpired: Boollet expiryDate: String?let cardNumber: String?let formattedNumber: String?let phoneNumber: String?init(isExpired: Bool, expiryDate: String? = nil, cardNumber: String? = nil, formattedNumber: String? = nil, phoneNumber: String? = nil) {self.isExpired = isExpiredself.expiryDate = expiryDateself.cardNumber = cardNumberself.formattedNumber = formattedNumberself.phoneNumber = phoneNumber}}

Software Developer(iOS), Speaker & Writer at Swift India