Proposal sanity check: assigning a case statement to a boolean

I would not use is case to extract associated values since the let/var keywords shouldn't be on the right side in an assignment expression. I would use something like as? case or as! case to extract payloads as written here and let enumerations gain the same benefits optionals have.

let associatedValue = enumValue as! case .aCase // force unwrapping
if let associatedValue = enumValue as? case .aCase { ... } // unwrapping

But this is far beyond the purpose of this thread.

2 Likes