Last active
December 8, 2021 17:34
-
-
Save philosopherdog/ee7d48e092c0c0b4867758791351c121 to your computer and use it in GitHub Desktop.
Swift Unwrap Enum Associated Type Without Switch #enum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum CommunityProfileSection { | |
case FacilityName(String?) | |
case ContactInfo(ProfileContactViewModel) | |
case LocationInfo([ExpandableProfileModel]) | |
} | |
extension CommunityProfileSection { | |
var facilityName: String? { | |
if case let .FacilityName(name) = self { | |
return name | |
} | |
return nil | |
} | |
var locationInfoList: [ExpandableProfileModel] { | |
if case let .LocationInfo(list) = self { | |
return list | |
} | |
return [] | |
} | |
var contactInfo: ProfileContactViewModel? { | |
if case let .ContactInfo(info) = self { | |
return info | |
} | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment