# Extracting parametric types

**URL:** <https://discourse.julialang.org/t/extracting-parametric-types/4298>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 16, 2017, 8:09am UTC](https://discourse.julialang.org/t/extracting-parametric-types/4298 "2017-06-16T08:09:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivin9](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@shivin9](https://discourse.julialang.org/u/shivin9)\
**Post date:** [June 16, 2017, 8:09am UTC](https://discourse.julialang.org/t/extracting-parametric-types/4298/1 "2017-06-16T08:09:19Z")

</div>

Hi,  
I have an object defined as `A = LinearOperator{Float64}(2,2,1000,:D0,:D0,[-1,-1])`  
so when I do `typeof(A)`, I get  
`PDEOperators.LinearOperator{Float64,SVector{3,Float64},:D0,:D1}` (doing this with inner constructors and all)  
so now I want to extract the `:D0` and `:D1`.  
is it possible without string manipulations ie. using features of the language itself?

---

<div class="post-metadata">

**Author:** ![shivin9](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@shivin9](https://discourse.julialang.org/u/shivin9)\
**Post date:** [June 16, 2017, 8:19am UTC](https://discourse.julialang.org/t/extracting-parametric-types/4298/2 "2017-06-16T08:19:07Z")

</div>

Solved by @oxinabox on gitter.

```julia
julia> typeof(typeof(A).parameters)
SimpleVector

```

so doing

```julia
julia> typeof(A).parameters[end]
:D0

```

we get the required parameter.

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [June 16, 2017, 8:41am UTC](https://discourse.julialang.org/t/extracting-parametric-types/4298/3 "2017-06-16T08:41:49Z")

</div>

But note that this is not type stable as `SimpleVector` has no type information on its contents. Thus, if possible, it is better (and more Julian) to use parametrized functions:

```julia
get_D0_D1{A,B,C,D}(::LinearOperator{A,B,C,D}) = C,D

```
