Skip to content

quantity(FloatType, unit) function #385

@MartinOtter

Description

@MartinOtter

Declaring a Unitful unit in a struct could be made nicer, if the following function quantity(..) is provided in Unitful:

using Unitful

# The following function should be defined inside Unitful
quantity(FloatType, unit) = Quantity{FloatType, dimension(unit), typeof(unit)} 

mutable struct Data{FloatType <: AbstractFloat}
    length::quantity(FloatType, u"m")
end

L = Data{Float64}(2.0u"mm")
@show L

Of course, it is easy to introduce such a function in an own package. However, it would be better if this feature is directly provided by Unitful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions