This is actually quite a good solution. It wouldn’t be quite as consistent if I had multiple catch statements for different types before this but it really gets almost all of the way there. Thanks!
> On Mar 21, 2016, at 6:20 PM, Michel Fortin <[email protected]> wrote: > > 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
