# Subtyped parameters in constructors

**URL:** https://discourse.julialang.org/t/subtyped-parameters-in-constructors/127287
**Category:** General Usage
**Tags:** question, constructors
**Created:** [March 23, 2025, 7:48pm UTC](https://discourse.julialang.org/t/subtyped-parameters-in-constructors/127287 "2025-03-23T19:48:40Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [March 23, 2025, 8:27pm UTC](https://discourse.julialang.org/t/subtyped-parameters-in-constructors/127287/3 "2025-03-23T20:27:16Z")

</div>

Not sure why you want this, but one approach is to dispatch on all subtypes of your type. For correctness, you may need to keep in mind that `Union{}` subtypes all types.

```julia
function (::Type{Q})(v, u) where {Q <: Quantity}
    # constructor code here
end

```

Also keep in mind there’s currently no generic way to access a bound (either lower or upper) of a type variable, see:

- [[FR] a new variant on method static parameter matching for getting the upper bound](https://discourse.julialang.org/t/fr-a-new-variant-on-method-static-parameter-matching-for-getting-the-upper-bound/118261)

---

_[View the full topic](https://discourse.julialang.org/t/subtyped-parameters-in-constructors/127287)._
