News for hackers. Stuff that matters.
Re:Is Apple Using Swift? by billconan on Monday January 18, 2016 @02:05PM (#10926163)
I'm curious, if my variable "a" is indeed null, and when I say a!, what will happen?

will it be a runtime error? like a memory access violation in c++?

what's the benefit of adding !? if it generates the same access violation runtime error?

Re:Is Apple Using Swift? by rockshassa on Monday January 18, 2016 @02:41PM (#10926411)
yes, it is a runtime error. given the code

let foo = bar!

If bar is nil, you'll get a runtime error "unexpectedly found nil when unwrapping bar"

in my opinion, the benefit of optionals in general is that it allows you to guarantee at compile time that certain variables (non optionals) will _never_ be nil, which enables all kinds of compiler optimizations.