News for hackers. Stuff that matters.
Re:From Rust to TypeScript by kibwen on Saturday September 12, 2020 @12:33PM (#24453616)
I'm no Swift expert, but I don't believe that any changes have been made to its idiomatic error-handling approach. Using the first example from the Swift 5.3 docs ( https://docs.swift.org/swift-book/LanguageGuide/ErrorHandlin... ):

    func buyFavoriteSnack(person: String, vendingMachine: VendingMachine) throws {
        let snackName = favoriteSnacks[person] ?? "Candy Bar"
        try vendingMachine.vend(itemNamed: snackName)
    }
The `try` is analogous to Rust's `?`, and the `throws` is the part of the type signature that indicates that the function may error but without any additional information about how it may error. Of course, I imagine a capable IDE should still be able to inspect all the `try`s in a function to determine what types can possibly be thrown.

There are no comments on this comment yet.