§ How it works
Kirchhoff's voltage law around the loop gives a first-order differential equation, . Its solutions are exponentials with time constant :
An inductor resists sudden changes of current: at the full source voltage appears across it and the current starts rising at . After one the current reaches 63.2 %, after it is within 1 % of the final value.
When the source is disconnected, the stored energy must go somewhere. With a freewheel path (diode or resistor) the current decays through . Without one, becomes huge and so does : the spark that kills relay contacts and transistors driving coils.