In Swift2, you might have something similar to the following code:
switch productIdentifier { case hasSuffix("q"): return "Quarterly".localized case hasSuffix("m"): return "Monthly".localized default: return "Yearly".localized }
and it will work. In Swift 3, the only way I can do the above is:
switch productIdentifier { case let x where x.hasSuffix("q"): return "Quarterly".localized case let x where x.hasSuffix("m"): return "Monthly".localized default: return "Yearly".localized }
which seems to be losing the clarity of the Swift2 version, and it makes me think that I was missing something. The above version is, of course, simple. I'm curious if anyone has a better way to handle this?
source share