> On Jul 13, 2017, at 10:21 PM, Félix Cloutier via swift-evolution
> wrote:
>
> How should the fix-it transform the following code to make it valid?
>
> func foo(bar: String) -> Int
> func frob() -> String?
>
> func qaz() -> Int {
> return foo(bar: frob()) // frob() is optional, insert
Another example of the compiler being not so helpful:
func f(completion: (()->())? = nil) {
completion()
}
The compiler offers to insert a ! after `completion`, which is a strictly worse
choice than inserting a ?.
> On Jul 15, 2017, at 7:48 AM, Rod Brown wrote:
>
>>
>> On 15 Jul 2017
> On 15 Jul 2017, at 9:54 am, Robert Bennett via swift-evolution
> wrote:
>
> For expressions whose type is definitely non-optional, it makes sense to
> verbally suggest both ! and ?? (and/or !! – was that accepted?), and it’s
> probably best to insert ! when the fixit is accepted. For expres
For expressions whose type is definitely non-optional, it makes sense to
verbally suggest both ! and ?? (and/or !! – was that accepted?), and it’s
probably best to insert ! when the fixit is accepted. For expressions whose
type is undetermined, but which need some form of Optional handling, it w
> On Jul 14, 2017, at 2:11 AM, Víctor Pimentel via swift-evolution
> wrote:
>
>> On 14 Jul 2017, at 08:05, Rod Brown via swift-evolution
>> wrote:
>>
>>
>>
>>> On 14 Jul 2017, at 2:36 pm, Robert Bennett via swift-evolution
>>> wrote:
>>>
>>> When writing Swift code, it is not uncommon t
> On 14 Jul 2017, at 08:05, Rod Brown via swift-evolution
> wrote:
>
>
>
>> On 14 Jul 2017, at 2:36 pm, Robert Bennett via swift-evolution
>> wrote:
>>
>> When writing Swift code, it is not uncommon to forget to unwrap optionals.
>> The compiler will offer a fixit, telling you you must ins
> On 14 Jul 2017, at 2:36 pm, Robert Bennett via swift-evolution
> wrote:
>
> When writing Swift code, it is not uncommon to forget to unwrap optionals.
> The compiler will offer a fixit, telling you you must insert either a ? or a
> !. However, when you accept the fixit, ! is inserted (at l
How should the fix-it transform the following code to make it valid?
func foo(bar: String) -> Int
func frob() -> String?
func qaz() -> Int {
return foo(bar: frob()) // frob() is optional, insert a ! to fix
}
> Le 13 juil. 2017 à 21:36, Robert Bennett via swift-evolution
> a écrit :
>
When writing Swift code, it is not uncommon to forget to unwrap optionals. The
compiler will offer a fixit, telling you you must insert either a ? or a !.
However, when you accept the fixit, ! is inserted (at least, it is for me in
Xcode 8.3).
Ideally the fixit would default to ? because this i