4 ms·
> "This is probably the least-Swift thing ever, but, if you're used to coding in this style, it's fantastic." As someone who has been building on Objective-C f
by potatolicious 4y ago
> "This is probably the least-Swift thing ever, but, if you're used to coding in this style, it's fantastic."
As someone who has been building on Objective-C for >10 years now... it's horrible. Sure, there's less compiler-yelling-at-you-itis, but the code sample the author gives is almost certainly the single biggest source of bugs in Objective-C codebases.
The inclusion of Optionals in Swift is specifically to, in one fell swoop, eliminate the single largest source of bugs in Obj-C codebases.
I get the appeal of getting the compiler to be less strict and yell at you less for just hacking around - but something you use to write production code needs be very liberal about error detection and yelling at you.
Not to mention the same lack of verbosity is supported in Swift with all of the safeties of optionals:
`if dict?.keys.contains("a")`
Which is both semantically and typographically terser, and makes the intention of the code clear (i.e., "dict" is expected to sometimes be nil)