The ray_switch node lets you evaluate different shading trees for different ray types. In general, it’s used to provide a simpler shading tree for secondary rays, such as diffuse, glossy, or shadow rays. So when a camera ray hits the object, you can do one thing, but when a secondary ray hits the object, you can do another, simpler thing🙂
For shadow rays, it’s not the color that matters, but whether the object blocks the shadow ray from a light. For example, if an object is opaque, then it doesn’t matter whether ray_switch returns red or blue or green or yellow for the shadow rays: the object is still opaque and blocking the light. So, you could use a ray_switch.shadow to plug in a simple standard shader that provides just the opacity mask.