[swift-evolution] [Draft] Abolish IUO type
jed.lewison at icloud.com
Thu Mar 17 15:45:11 CDT 2016
> On Mar 17, 2016, at 12:16 AM, Chris Willmore via swift-evolution <swift-evolution at swift.org> wrote:
> To run with the example above, emailTextField would have type UITextField? but, because it’s an IUO declaration, it would still be usable in contexts that required non-optional UITextField. What would change is that if you were to say, e.g.
> let textField = controller.emailTextField
> then textField would have type UITextField?. But you could still say
For this scenario, would you be able to implicitly force-unwrap when a non-optional is not required, like:
controller.emailTextField.minimumFontSize = 12
Or would you have to say:
controller.emailTextField?.minimumFontSize = 12
If the former, would fontSize be an Optional<CGFloat> or a CGFloat (non-optional)?
let fontSize = controller.emailTextField.minimumFontSize
As a user, I’m not sure which I’d expect. Given the behavior of let textField = controller.emailTextField, it seems like i’d expect fontSize to be an Optional<CGFloat>. Then again, if I’m allowed to implicitly unwrap emailTextField, it also doesn’t make any sense for fontSize to be an Optional. (I’m assuming that there would not be a circumstance where the IUO-ableness of the value would be preserved.)
On a different note: As a general rule, I’m +1_000_000 on anything that makes IUO and force-unwrapping less common, so anything with the subject “Abolish IUO Type" makes me smile.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution