# Subtype of template parameter

**URL:** <https://discourse.julialang.org/t/subtype-of-template-parameter/38830>\
**Category:** General Usage\
**Created:** [May 5, 2020, 8:26pm UTC](https://discourse.julialang.org/t/subtype-of-template-parameter/38830 "2020-05-05T20:26:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![atteson](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@atteson](https://discourse.julialang.org/u/atteson)\
**Post date:** [May 5, 2020, 8:26pm UTC](https://discourse.julialang.org/t/subtype-of-template-parameter/38830/1 "2020-05-05T20:26:44Z")

</div>

Is there a way to implement something like the following:

```julia
abstract type T1{T} <: T
end

```

I’m creating a type which sometimes acts like a Real (and I want to use it in packages that require Real) and sometimes acts like \<: AbstractVector{Real}.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [May 5, 2020, 9:36pm UTC](https://discourse.julialang.org/t/subtype-of-template-parameter/38830/2 "2020-05-05T21:36:41Z")

</div>

This isn’t possible currently. Why do you want to do this? There may be a different way to set things up that works.

---

<div class="post-metadata">

**Author:** ![atteson](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@atteson](https://discourse.julialang.org/u/atteson)\
**Post date:** [May 5, 2020, 11:40pm UTC](https://discourse.julialang.org/t/subtype-of-template-parameter/38830/3 "2020-05-05T23:40:36Z")

</div>

I want to build a type which can be passed into Distributions as scalar parameters. These are Real. However, my type can also be a Vector for other purposes.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [May 5, 2020, 11:46pm UTC](https://discourse.julialang.org/t/subtype-of-template-parameter/38830/4 "2020-05-05T23:46:36Z")

</div>

Why do you need something which sometimes behaves as an array, and sometimes as a scalar? This feels like a case where you should just have 2 different types.

---

<div class="post-metadata">

**Author:** ![atteson](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@atteson](https://discourse.julialang.org/u/atteson)\
**Post date:** [May 5, 2020, 11:47pm UTC](https://discourse.julialang.org/t/subtype-of-template-parameter/38830/5 "2020-05-05T23:47:37Z")

</div>

I’d then have to replicate a lot of code to implement each. Anyway, I understand it can’t be done in julia.
