Certainly both of these excellent short stories are famed for their use of irony and how the surprising twists in both tales yield unforgettable endings. However, when we think of irony, it is important to recall that there are three types: dramatic irony, situational irony, and verbal irony. Dramatic irony is when the audience and other characters know something that a character does not in a play or a novel. One of the best examples is the dramatic irony in Romeo and Juliet, when we as an audience know that Juliet is not dead, but Romeo does not, and kills himself anyway. Verbal irony is when a character says something but actually means the opposite of what they say. Lastly, situational irony describes an event that is actually contrary to what we expected, giving us a surprise ending.
It is clear, therefore, that when we consider the three types of irony, it is situational irony that is used in both of these tales to devastating effect. It is only in the last lines that we are told that Captain Torres knew about the barber's associations with the rebels, and it is only towards the end of "The Gift of the Magi" that we are told what precisely Jim has sold to buy Bella her beloved combs. The surprise endings in both of these excellent stories is what makes them truly memorable.