SwiftLuhn icon indicating copy to clipboard operation
SwiftLuhn copied to clipboard

Card type detection fixed

Open nagarro-mohitpadalia opened this issue 6 years ago • 6 comments

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.

nagarro-mohitpadalia avatar Jan 04 '19 06:01 nagarro-mohitpadalia

@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?

https://gist.githubusercontent.com/polac24/f33791151e22d4787a09262d66f01bcd/raw/8ea9e37fae685fb9f21fbbbfaa601e51f2b927af/IntEnum.swift

Stolen from: https://medium.com/@londeix/listing-all-cases-in-an-enum-3b057f2c1432

maxkramer avatar Jan 04 '19 08:01 maxkramer

@maxkramer

I have done the suggested change you can review and merge.

nagarro-mohitpadalia avatar Jan 04 '19 10:01 nagarro-mohitpadalia

@nagarro-mohitpadalia that's great, thanks a lot for your support! Just waiting for CI, and will then get that merged!

maxkramer avatar Jan 04 '19 10:01 maxkramer

@nagarro-mohitpadalia circleci have removed our free plan for Mac OSX builds, currently waiting for them to renew it. Will merge thereafter.

maxkramer avatar Jan 07 '19 15:01 maxkramer

@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 avatar Jan 07 '19 23:01 maxkramer

@maxkramer I have pushed dummy commits, hope this will trigger the CI build

nagarro-mohitpadalia avatar Jan 08 '19 07:01 nagarro-mohitpadalia