[swift-evolution] Proposal: An assignment operator := that ensures nil before assignment.
Amir Michail
a.michail at me.com
Sat Feb 27 11:02:41 CST 2016
> On Feb 27, 2016, at 11:30 AM, Stephen Celis <stephen.celis at gmail.com> wrote:
>
>> On Feb 27, 2016, at 11:28 AM, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> It’s a convenience feature that saves lots of finger typing.
>>
>> Which would you rather have:
>>
>> precondition( x == nil )
>> x = 3
>>
>> OR
>>
>> x: = 3
>>
>> ?
>
> A bunch of us have tried to point out that toy examples like these are not helpful enough.
>
Here’s a use case. Suppose you are filling out a dictionary in some non-trivial way. However, it should be the case that the value for each key is computed and assigned only once. And so you would use the := operator to ensure this: dictionary[k] := value
> You're not addressing the actual content and questions of any of your replies, Amir. Would you please take the time and effort to do so?
>
> --
> Stephen
More information about the swift-evolution
mailing list