Hacker News new | past | comments | ask | show | jobs | submit login

I'm not sure if this is the case in your example, but at least in Swift, the "if let" block or chaining for optionals is mandatory. This should mean that it's impossible to have a dangling/null pointer unless you use the force dereference operator. (And that's something that should almost never appear in your code!) You don't get the choice of being lazy or forgetting about checking your pointers: it's a conscious decision either way.

Personally, I appreciate that the language naturally makes me organize my code better and more safely.




It is, and you can pattern-match Optional in Swift, something along the lines of

    switch optional {
    case .Some(let numeral):
        println("Caught a \(numeral)")
    default:
        println("Nothing to catch")
    }




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

Search: