If the cap fits ie the attachment end goes in the slot I don’t see why it wouldn’t work.
I think it should be made clear that this only applies with any degree of safety to modern devices from reputable manufacturers and designed to plug into a multiplicity of different computers and the like.
Other devices, even if they use the same plug, may have very different power requirements and if they, or the power supply or lead, came from a dubious manufacturer or seller of cheap look-alikes on the internet or a market stall you need to proceed very warily. Although it is true that a device should only take the current it needs from a power supply, some rely on vital features being provided in the power supply used multiple times rather than the cheap throwaway device itself. This notoriously includes current-limiting to prevent over-charging, which had lead to fire or explosion in a number of recently-publicised cases.
The "if it fits" rule rule should never be applied without circumspection to those devices which use cylindrical "coaxial" power connectors of various diameters. The electrical requirements, however, are many and various. Apart from voltage and current differences, they could be AC or DC and if the latter, polarity and whether stabilised or unstabilised. An unstabilised supply will give a much higher voltage when off-load and this can kill an expensive device that doesn't have its own internal regulation.
In short, mix and match power supplies and devices with extreme caution.