38a I was thinking about biology--though not especially hard--when suddenly I realized I had missed the test.
Parentheses would have performed the same function, but they would have integrated the aside more subtly into the sentence. Dashes indicate an interruption while parentheses signal a digression.
If you use dashes in this way, make sure that the sentence makes sense without them. The biology example above would be faulty if it read like this:
38b I was thinking about biology--realizing I had a test--and I had missed it.
If the material between the dashes is removed, the sentence reads
38c I was thinking about biology and I had missed it.
An important piece of information is now missing, and the sentence makes no sense. Therefore the sentence is incorrect even with the dashes restored.
The dash has an ironic quality that is useful in informal writing. For example, in the following sentence, a colon could have been used in place of the dash, but the dash brings out the sarcasm:
39 We had a magnificent feast--Twinkies and Kool-Aid.
This kind of usage should be confined to informal writing as it tends to be humorous or flippant:
40 That lecture was interesting--or at least it kept me awake.