Open nagarro-mohitpadalia opened 5 years ago
@nagarro-mohitpadalia thanks a lot for your support! That's a good find, and I'm surprised that the CaseIterable doesn't support enum int
associated values, as enums are usually integer based already.
I think it would probably be better to use something along the lines of the following to ensure that we don't have an issue in the future with adding additional cases and forgetting to update the count variable. This loops through 1..n to calculate all cases. What are your thoughts?
Stolen from: https://medium.com/@londeix/listing-all-cases-in-an-enum-3b057f2c1432
@maxkramer
I have done the suggested change you can review and merge.
@nagarro-mohitpadalia that's great, thanks a lot for your support! Just waiting for CI, and will then get that merged!
@nagarro-mohitpadalia circleci have removed our free plan for Mac OSX builds, currently waiting for them to renew it. Will merge thereafter.
@nagarro-mohitpadalia CircleCI have now fixed the issue. Please could you push the commit again / push a blank commit to trigger the CI build?
@maxkramer I have pushed dummy commits, hope this will trigger the CI build
Hi @maxkramer
The PR fixes the issue #18
The caseIterable protocol works for enumerations without associated values, so I have added a simple solution to get the count of all enum cases:
Please review.