News for hackers. Stuff that matters.
Re:Swift 1.2 and Xcode 6.3 beta by archagon on Monday February 09, 2015 @06:57PM (#9024615)
I'm not a language guy so I don't know anything about generalized pattern matching. Maybe it is better. But for my own use, "if let" ensures that I always take care of any possible nulls in my code, while also keeping the conditional code in the same scope as the verified variable. There's no easy way to leave pointers dangling or uninitialized. The language design forces me to organize and think about my code in a much better way.
Re:Swift 1.2 and Xcode 6.3 beta by wyager on Monday February 09, 2015 @09:46PM (#9025111)
With generalized pattern matching, your code could (among other things) take the form of

    case result of
        Just x -> <do something with x>
        Nothing -> <do something without x>
This works with optionals as well as any other algebraic data type.
Re:Swift 1.2 and Xcode 6.3 beta by archagon on Monday February 09, 2015 @10:09PM (#9025176)
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.

Re:Swift 1.2 and Xcode 6.3 beta by masklinn on Tuesday February 10, 2015 @03:55AM (#9026035)
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")
    }