Think the ternary operator, but worse.
In Swift, this is expressed by "??".
It means "If the previous test returns nil, then execute what is after the ??".
For example, if you have a concrete Int, but the source might be an optional, then you could do something like this:
let a = b ?? 0
That means that if b is nil, then set a to 0. Otherwise, set it to whatever value b has.
You can chain these, like so:
let b: Int? = <something from somewhere>
let c: Int? = <something from somewhere>
let a: Int = b ?? c ?? 0
So you have a couple of optional values coming in, but they could be nil, so you chain them.
You can have a lot more going on in the handlers than simple assignments, but this gives you an idea.
In Swift, this is expressed by "??".
It means "If the previous test returns nil, then execute what is after the ??".
For example, if you have a concrete Int, but the source might be an optional, then you could do something like this:
That means that if b is nil, then set a to 0. Otherwise, set it to whatever value b has.You can chain these, like so:
So you have a couple of optional values coming in, but they could be nil, so you chain them.You can have a lot more going on in the handlers than simple assignments, but this gives you an idea.