How To Properly Use Unitful

Late to the thread, but fyi, thereโ€™s something sneaky being done here to keep Unitful types from being exceedingly long when printed, which is something people have disliked in the past. The cm^-3 inside the type signature is actually this:

julia> Unitful.Unit{:Meter, u"๐‹"}(-2,-3)
cmโปยณ

The Unitful.Unit type is never manipulated by the user and is for internal use only. Having Unitful types show in a succinct way that still yields enough information to construct the type at the REPL has proven challenging. I think a step in the right direction would be to at least distinguish the two cm objects by having the internal one display differently, to avoid pulling a fast one on everyone. Sorry for that.

If you find yourself wanting to manipulate Unitful types directly, thereโ€™s almost always a better way. I would follow Timโ€™s advice here. You could consider restricting to cm^-3 in the constructor if desired, though Iโ€™m not sure why you would need to do that.