As a literary device, irony is a contrast or incongruity between expectations for a situation and what is reality.
This can be a difference between the surface meaning of something that is said and the underlying meaning. It can also be a difference between what might be expected to happen and what actually occurs.
The writer can use three types of irony. The first is verbal irony. Essentially, the intended meaning of a statement is different from the actual meaning. It is often a form of sarcasm.
The second type is situational Irony. It occurs when the expected outcome of an action is different than the actual outcome.
The last type is dramatic irony. Essentially, the audience knows more about the character’s situation than the character does.