Q:

In projectile.el's source code, how does switch-project-action "know" which project to switch to?

In this function definition snippet, a call to switch-project-action is done without any arguments. How does it switch to the correct project?
(defun projectile-switch-project-by-name (project-to-switch &optional arg)
  "Switch to project by project name PROJECT-TO-SWITCH.
Invokes the command referenced by `projectile-switch-project-action' on switch.
With a prefix ARG invokes `projectile-commander' instead of
`projectile-switch-project-action.'"
  (let* ((default-directory project-to-switch)
         (switch-project-action (if arg
                                    'projectile-commander
                                  projectile-switch-project-action)))
    (run-hooks 'projectile-before-switch-project-hook)
    (funcall switch-project-action)
    (run-hooks 'projectile-after-switch-project-hook)))

A:

The current project is determined by the value of default-directory, which is let-bound to "switch" projects before calling the action.

