Xcode6-Beta2 (6A216f): Swift cannot set properties via optionals
| Originator: | tony | ||
| Number: | rdar://17500804 | Date Originated: | 30-Jun-2014 11:14 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode6-Beta2 (6A216f) |
| Classification: | Enhancement | Reproducible: | Not Applicable |
Summary: I would expect to be able to set a property via an optional, however this results in a compiler error. Steps to Reproduce: Given the following syntax: someObject?.value = anotherValue Expected Results: The someObject’s value property is set to anotherValue if someObject is not None. If someObject is None, then the call does nothing. Actual Results: Xcode reports an error: “Cannot assign to the result of this expression” Notes: I understand that I can use the `if let someObject = blah` syntax to conditionally check and unwrap the optional, but it would be nice to have simple syntax like we have for property getters.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!