logoalt Hacker News

ardit33yesterday at 10:49 PM1 replyview on HN

I hate how pendantic and useless some of the features of swift being pushed down by academics that don't write apps or services themselves.

Simple example:

Objective-C

if myObject {

}

in swift if myObject != nil {

}

Also opitionals in swift could have totally be avoided if they adopted a prototype based langue (basically object are never nil). Lua did this, and it is very elegant

But meanwhile, we got a half backed optional system, which is backwards (similiar to Java), and didn't help with the practicality of the language at all, and meanwhile you still can crash an app doing myArray[1]


Replies

andrekandretoday at 12:59 AM

  > you still can crash an app doing myArray[1]
the first thing i do when starting a new project:

  extension Array {
      subscript(safe: Int) -> Element? { ... }
  }
there was talk in the swift forms about adding that as standard that but it seems to have died off...

[0] https://forums.swift.org/t/draft-adding-safe-indexing-to-arr...