In Swift2, you could 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 would work. In Swift 3, the only way I can make the above work 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 lose the clarity of the Swift2 version - and it makes me think I'm missing something. The above is a simple version of course. I'm curious if anyone has a better way of handling that?