# Help with parametric definition (Unitful.jl)

I need some help with the definition of a function, using the unitful package.
i know that the units have the dimensions inside the type, and i need to access that information.
uniful.jl provides the function dimension(T) and dimension(x::T), that gives the correct dimension information, so that:

``````dimension(u"L/mol") == dimension(123.0u"m^3/kmol)
true
``````

i need some help defining a function that accepts a unitful type with specific dimensions, something like this:

``````using Unitful
function testdim(x::T) where dimension(T) == dimension(1.0u"L/mol")
return 1
end
``````

a little more information, the value x is of type x::Unitful.Quantity{U,D}), so this simplifies the definition:

``````using Unitful
function testdim2(x::Unitful.Quantity{U,D}) where {U,D == dimension(u"K")}
return 1
end
``````

this doesn’t work yet, but is close

Do you look for something like this

``````f(x::Quantity{<:Number, Unitful.𝐋^3*Unitful.𝐍^-1}) = 1
``````

or maybe

``````function testdim2(x::Unitful.Quantity{U,D}) where {U,D}
return D == dimension(u"K")
end
``````

?

The first one seems like a solution to me! I don’t have a computer right now, but I will inform you about the results!