I'm using something like the OP's snippet as part of a garbage collector, but wanted to share part of my learning curve. When using createCreep with a memory argument, that creeps memory created and available to code for the remainder of that tick. The creep itself isn't available until the start of the next tick.
My first pass had an OP style GC at the end of my code, and I couldn't figure out why my creeps memory were being wipe before the creep was even being created. What was happening was:
This tick:
createCreep called with memory argument
Memory.creeps.myNewCreep available
GC runs seeing Memory.creep.myNewCreep but not Game.creep.myNewCreep so deletes Memory.creep.myNewCreep
Next tick:
Game.creep.myNewCreep has no memory.
Moving the GC earlier in the tick solved the problem.
This tick
run GC, myNewCreep hasen't been created yet, so isn't deleted
createCreep
Memory.creep.myNewCreep available
Next tick
Now when GC runs both Memory and Game versions of myNewCreep are available, so it is not deleted from memory.
TL;DR: If you use this snippet, use it very early in your code.