We may have been taught the speed of light is constant. In actuality, the speed of light depends upon the medium through which it travels. The speed of light varies. As an example, consider how the speed of light varies as it travels through diamond, air or glass.
Snell's Law and the Speed of Light
As is the case for all forms of energy, light interacts with matter. When light passes from one medium into another, the path of trajectory bends in accordance with Snell’s Law. That law states that the refractive index of the first substance times the sine of the angle of incidence equals the refractive index of the second substance times the sine of the angle of refraction, or,
n1sinθ1 = n2sinθ2
This is caused by the fact that light either speeds up or slows down when it changes media. The higher the index of refraction is, the slower the speed of light is. The indexes of refraction for diamond, air and glass are, respectively, 2.42, 1.00, and approximately 1.50, depending upon the composition of the glass. Light travels slowest in diamond.