Skip to content

Comment on Why Rubyist Will Love Swiftparent

Comments

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.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.