When learning a new concept, it is very common to experience dreams somehow related to the material. Some researchers hypothesize that dreaming is a nifty result of your brain’s biological process of long-term memory consolidation.
Defragging your brain during sleep allows short term memories to be re-encoded, by strengthening neural traces of recent events. This also serves to integrate these new traces with previously stored knowledge and older memories.
Have you ever dreamt in code?