Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

this is a very common in obj-c too

on the other hand, depending on what your trying to do you might want to provide more context about what happened to the user/programmer

in swift you can change a throwing function to a nullable with `try?` so even if `getUser()` throws, you can keep it simple if thats what is appropriate

  guard let user = try? getUser(id: someUUID) else {
      return "user not found"
  }
as an aside, swift "throws" exceptions but these are just sugar for returning basically an Result<T,E> and compose much better than traditional stack unwinding exceptions imo


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: