Hi, I've started learning Swift recently and have been using the swiftlint rules as a guide for good code practices. Regarding the force_cast error, code like this won't pass swiftlint:
someVar = someOptional as! OtherType
But this does:
someVar = (someOptional as? OtherType)!
Aren't those essentially the same thing? Shouldn't both trigger the force_cast error ?
No, because technically the second is not a force_cast, it is a force_unwrapping of an optional cast. force_unwrapping is an OptInRule that you can enable using enabled_rules in your configuration file.
I see, thanks for the help @scottrhoyt
Most helpful comment
No, because technically the second is not a
force_cast, it is aforce_unwrappingof an optional cast.force_unwrappingis anOptInRulethat you can enable usingenabled_rulesin your configuration file.