Basic editing for typos and code formatting are great!
But recently, I've had two types of edits that I was not sure how to handle:
They completely changed my code example.
They added additional suggestions to my answer.
What is the appropriate way to handle these types of edits?
As an example of (1), the OP asked how to do x with numbers. I pasted sample code (with a link to a github) that showed how to do x with objects and suggested they could extrapolate. Someone changed my entire example to do x with numbers. Now I'm sure this helped the OP, but was no longer my example nor did it then match the provided github reference.
As an example of (2), I provided several suggested techniques for achieving y. Someone added an edit with several more techniques.
In the first case, it seems like it would have been better for the person editing my post to provide their own answer instead of completely rewriting mine.
In the second case, I think comments would have been more appropriate. Adding someone else's thoughts/suggestions in my post implies to me that those are my suggestions.
How should these types of edits be handled?