[swift-evolution] [Pitch] Add Null struct to Foundation

Brent Royal-Gordon brent at architechies.com
Fri Jun 24 04:32:34 CDT 2016

> Not really. What is the type of Optional.none? `let empty = Optional.none` does not compile, it says "Generic parameter 'Wrapped' could not be inferred". NSNull() is a unique concrete value, and it's compatible with Objective C, NSObject and AnyObject. We could of course use `Optional<Int16>.none`, but someone else may use `Optional<AnyObject>.none` instead. The extra type information is just misleading in this case.

If you want a single, unique value, use `()`.

But I'm not sure why you wouldn't just make this member an Optional<Any> in the first place. Is there some reason that wouldn't be suitable?

Brent Royal-Gordon

More information about the swift-evolution mailing list