Is there an equivalent to optional chaining with arithmetic operators?
I have two optional numbers that I add. Now it looks like this:
if let a = optionalA {
if let b = optionalB {
return a + b
}
}
return nil
There is a more convenient additional chaining syntax for methods, such as syntax optionalA.?method
. Is there an equivalent for arithmetic operators returning nil
if each side was nil
?
+3
source to share
3 answers