code: private Environment switchEnvironment(Environment env) {
      Environment prev = currentEnvironment;
      currentEnvironment = env;
      return prev;
    }
docs: Switch to a new environment
  
  @param env Environment to switch to
  @returns Previous environment