You're seeing just the function new, go back to Cldr.Unit module for more information.
Link to this function

new(value, unit, options \\ [])

View Source


new(unit() | value(), value() | unit(), Keyword.t()) ::
  {:ok, t()} | {:error, {module(), String.t()}}

Returns a new Unit.t struct.



  • :usage is the intended use of the unit. This is used during localization to convert the unit to that appropriate for the unit category, usage, target territory and unit value. The usage must be defined for the unit's category. See Cldr.Unit.unit_category_usage/0 for the known usage types for each category.


  • unit or

  • {:error, {exception, message}}


iex>, :gallon)
{:ok,!(:gallon, 23)}

iex>, 23)
{:ok,!(:gallon, 23)}

iex>, :gadzoots)
{:error, {Cldr.UnknownUnitError,
  "Unknown unit was detected at \"gadzoots\""}}, 23, usage: :fluid)
#=> {:ok, #Cldr.Unit<:gallon, 23, usage: :fluid, format_options: []>}