I find it helpful to think of capacitors and inductors to be complimentary.

<!-- Begin schematic: In order to preserve an editable schematic, please
     don't edit this section directly.
     Click the "edit" link below the image in the preview instead. -->

![schematic](https://i.sstatic.net/gpIZx.png)

<!-- End schematic -->

*Figure 1. Ideal and imperfect components.*

- Capacitors store energy in an electric field. Inductors store energy in a magnetic field.
- A capacitor stores energy when open circuit. An inductor stores energy when short circuited.
- Capacitors lose energy through parallel leakage resistance. Inductors lose energy through series resistance.
- Capacitors "like" to keep the voltage across them constant. Inductors like to keep the current through them constant.
- When a capacitor is short circuited the resultant current is very high. When an inductor is open-circuited the resultant voltage is very high.

>... when an inductor is disconnected the magnetic field starts collapsing inducing a very high voltage, wouldn't this voltage breaks down any transistors used in the switching from the charging to the discharging circuit?

Yes it would but there's a simple solution:

[![enter image description here][1]][1]

*Figure 2. A simple buck converter. Source: [All About Circuits](https://www.allaboutcircuits.com/technical-articles/utilization-of-simple-converters-circuits/).*

In Figure 2 S is the transistor switch. When it is switched off D maintains the current through L keeping it "happy" and avoiding a transient high voltage.

  [1]: https://i.sstatic.net/Evkkq.png