# How to deal with the changes in the Swift programming language?

I recently re-visited a question in and noticed that all code from the question and the answers doesn't compile anymore with the current Swift 2.1 release that comes with Xcode 7.2.

The reason is of course that Swift is an evolving language, and incompatible changes were made between releases (in particular in the transition to Swift 1.2/Xcode 6.3 and Swift 2.0/Xcode 7). These changes range from

• "minor changes", such as renaming println to print, over
• "medium changes", such as replacing most global function by protocol extension methods, i.e. map(array, ...) becomes array.map(...), to
• "major changes", such as a completely new error handling model (throw/try/catch).

I wonder if this should have any effect on existing questions and answers. I assume that the answer is "NO", because

• we must not change the question, and
• each answer refers to the code as it was posted in the question.

The disadvantage however is that future visitors cannot copy/paste code from the answers into their project. Is there any recommendation how this could be handled?

I don't have the intention to edit all my Swift answers with each new Swift/Xcode release, but if I re-visit an answer (e.g. due to a voting change or comment), is there anything sensible that I can/should do?

Update: I am aware that the problem is not restricted to the Swift language (as pointed out in Quill's answer). One thing that might be different compared to other programming languages is that many (most?) Apple developers will install only the latest Xcode because

• Like Quill suggests, if you're going to edit an old answer anyway, I'd just add a caveat à la "Note: This pertains to an older, deprecated version of Swift, etc." and maybe include a link to the version history. That could help people out. Dec 23 '15 at 4:17
• "The disadvantage however is that future visitors cannot copy/paste code from the answers into their project." Code Review is about sharing knowledge, not about sharing code.
– Mast Mod
Dec 26 '15 at 14:51

Deprecated functions are not a new thing, and not a thing solely to . You don't need to edit every question to replace println, you simply need to understand those questions/answers contain old code.
Python went and changed from print statement to print(statement), and the existing questions weren't edited. Granted that the changes from Python 2.7 to 3 were a little larger.