4 ms·
I'm intrigued by optionals, but I feel like returning nil for objects in ObjC - a pattern I've always used - is kind of the same thing in a different like. Do y
by eddieroger 12y ago
I'm intrigued by optionals, but I feel like returning nil for objects in ObjC - a pattern I've always used - is kind of the same thing in a different like. Do you have experience with returning nil instead of objects? How does that compare to optionals?
- alex_marchant 12y agoYes, i did use that same pattern. And if you want to, you can kind of force Swift to do this (String! is an "unwrapped optional" and can be nil or have a value) but it feels unnatural. You definitely have to design a bit differently than ObjC. Luckily Swift's enums are amazing and you can return multiple values (through tuples), so there are great ways to return different types of values.