how to undo any function

522 views android
4

Is there a way to undo last function/method which is just finished to work?

for example I have a function:

fun changeInfo(isTrue: Bolean, num: Number) {
isTrue = false
num+=5

}

and many more functions. Each function start to work when user presses certain button on a screen. User should have possibility to undo his last action. Is there universal way to undo any function which just finished to work?

Of course, I can do this way:

 isTrue=true
 num-=5

but that to do if there is many functions? Is there easy way to undo any function (android)?

answered question

Please do not tag languages that are not related to your question.

1 Answer

12

No, you can't. I don't know any language or platform where you can do something like that.

Any code that your application executes modifies data in memory in some way (creates or destroys objects, changes values etc.). In order to undo changes made by that code operating system should save the full history of data modifications and that is practically impossible because of limited resources.

posted this

Have an answer?

JD

Please login first before posting an answer.