[OT] Swift removing minor features to piss me off

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 28 12:45:47 PDT 2016


On 4/28/16 3:39 PM, Nick Treleaven wrote:
> On Thursday, 28 April 2016 at 18:49:54 UTC, Steven Schveighoffer wrote:
>> 1. Swift 3 will no longer allow mutable variables as parameters.
>> Instead, your parameters will be immutable, or reference (inout). To
>> fix this, you can assign your immutable variable to a mutable one
>> (immutability is always head immutability in swift), or put this weird
>> statement in your function:
>>
>> var i = i
>
> Seems reasonable given that code could mutate a variable accidentally,
> e.g. due to a typo.

If you don't want to mutate it, don't put var in the parameter name. I 
put var there because I wanted to mutate it. Swift requires that 
already. It just now won't let you do it in the parameter declaration, 
you have to declare a new variable and use that if you want mutation.

-Steve


More information about the Digitalmars-d mailing list