Swift: implicitly unwrapped reference, unclear when unwrapping occurs + code readability issue.

Originator:raphael
Number:rdar://17339762 Date Originated:17-Jun-2014 10:18 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6
Classification:Enhancement Reproducible:Not Applicable
 
1. When using implicitly unwrapped reference and passing it to a function that takes an implicitly unwrapped reference as argument, it is unclear whether the unwrapping occurs when method is invoked or when the variable is first accessed within the method.

Documentation could be improved with that.

2. Also, it makes not very readable code:

myFunc(myInt)

This line can crash if argument is Int and myInt is nil, or not crash if it is internally processed as an optional if argument is Int!. But this cannot be determined by reading this line of code, which is a readability issue IMO.

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!