The correct response is to avoid compromising the quality of your answer. An edit that changes variable names without changing the substance of the answer appears okay to me, if you are so inclined to do so.
There have been cases where people have defaced their questions to avoid academic charges of cheating. When such edits are discovered they are reversed. Posts can get locked in extreme cases. I'm not aware of anyone defacing an answer but if this were to happen the response would be the same.
The posts we make on SO are meant to serve the community and not just the individuals who posted them. It's too bad if the OP did not consider the implications of seeking help on SO.
I went and checked the question in the case at hand here and found that the OP indeed defaced their question. I went ahead and rolled back. If you notice this happening on any question that you answer (or any question whatsoever), please do a roll back. If the OP keeps defacing, then flag for moderator attention so that a moderator locks the post or deletes it.
Actually, upon further inspection, it is even worse than I initially thought. This user has systematically removed essential information from their own questions. I've rolled back the whole lot.