Swift should support customizable nil behavior per class
| Originator: | heath.borders | ||
| Number: | rdar://17930637 | Date Originated: | 06-Aug-2014 08:45 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | n/a |
| Classification: | Enhancement | Reproducible: | n/a |
Summary: Switch should allow a class to handle method calls on nil in a customizable way. For example, in objective-c, all methods on nil respond by returning a 0 of some kind. However, in Swift, the compiler should have enough information to know what type the nil should have, and the compiler could then redirect the nil call to a custom nil object. For example, a String's nil object could return a -1 startIndex when rangeOfString is called. If no nil object is set, then the default nil behavior should occur. Steps to Reproduce: n/a Expected Results: n/a Actual Results: n/a Version: n/a Notes: n/a Configuration: n/a Attachments:
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!