Not looking at the detailed error

If you don’t really care about the details of the error you can use try? to run the throwing method which returns an optional type. It is set if it succeeds or nil otherwise. No need to setup a do {} catch {} block. For example:

let remaining = try? bakery.orderPastry(item: "Albatross",

amountRequested: 1, flavor: "AlbatrossFlavor")

This is nice and short to write but downside is that you don’t get any details if the request fails.

results matching ""

    No results matching ""