[swift-users] Assigning a variable to itself
saagar at saagarjha.com
Tue Feb 21 19:57:41 CST 2017
It appears that trying to assign a variable to itself is an error:
var foo = 5
foo = foo // error: assigning a variable to itself
However, I was thinking about this and was wondering why this is an error and not a warning. If, for example, the assignment had a side effect (e.g. a didSet block) I’d think it would be warning, possibly ignorable with a set of parentheses. Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users