You can undo that.
Just shake, shake, shake.
Many apps let you shake to UNDO the last action.
You can also shake your iPhone when you type to UNDO or REDO typing in most apps.
But like most good things, it can have a downside. Some users report that their iPhones constantly try to undo actions and display the pop-up alert. This is caused by excess shaking of the iPhone.
There's no on/off switch in iOS 8 or earlier. But iOS 9 will have an option to toggle this feature on or off.