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

The thing that's interesting about optional binding is Swift is that it is a special construct for unwrapping optionals, not a normal assignment. If you try to bind to something that is not an optional using that syntax, it won't work. For example:

  if let currentUserIsAuthorized = true { // COMPILE ERROR
    ...
  }
This makes it useful for the one case where you'd actually want it without introducing any pitfalls, because using it incorrectly will be a syntax or type error.


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

Search: