Le 20 mars 2016 à 16:26, Tyler Fleming Cloutier via swift-evolution
<[email protected]> a écrit :
>
> Would it be wise to allow force conversion for the cases in which the
> developer believes the match is exhaustive? ie
>
> do {
> let action = chooseAction(game)
> game = try game.applyAction(action)
> } catch let e as ActionError {
> game.failedAction = e
> } catch _ {
> fatalError(“This is an unfortunate bit of noise :/")
> }
>
> becomes
>
> do {
> let action = chooseAction(game)
> game = try game.applyAction(action)
> } catch let e as! ActionError {
> game.failedAction = e
> }
If you move the cast on the next line it'll compile and do what you want with
exactly the same amount of code:
do {
let action = chooseAction(game)
game = try game.applyAction(action)
} catch let e {
game.failedAction = e as! ActionError
}
--
Michel Fortin
https://michelf.ca
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution