I was worried an in-place replace might cause problems because of the self-reference of of .subclasses inside the block, but if it works, great.

Also, IMO the local var should be called classes instead of subclasses, to reduce confusion with method name, and make it clear it only becomes subclasses at the end of the loop.