Cldr.Unit.Conversion.convert
You're seeing just the function
convert, go back to Cldr.Unit.Conversion module for more information.
Specs
convert(Cldr.Unit.t(), Cldr.Unit.unit()) :: {:ok, Cldr.Unit.t()} | {:error, {module(), String.t()}}
Convert one unit into another unit of the same unit type (length, volume, mass, ...)
Arguments
unitis any unit returned byCldr.Unit.new/2to_unitis any unit name returned byCldr.Unit.known_units/0
Returns
a
Unit.tof the unit typeto_unitor{:error, {exception, message}}
Examples
iex> Cldr.Unit.convert Cldr.Unit.new!(:mile, 1), :foot
{:ok, Cldr.Unit.new!(:foot, 5280)}
iex> Cldr.Unit.convert Cldr.Unit.new!(:mile, 1), :gallon
{:error, {Cldr.Unit.IncompatibleUnitsError,
"Operations can only be performed between units with the same base unit. Received :mile and :gallon"}}