# Some unexplained example in defining concrete type from an abstract type with multiple parameters

**URL:** <https://discourse.julialang.org/t/some-unexplained-example-in-defining-concrete-type-from-an-abstract-type-with-multiple-parameters/26581>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [July 20, 2019, 11:23am UTC](https://discourse.julialang.org/t/some-unexplained-example-in-defining-concrete-type-from-an-abstract-type-with-multiple-parameters/26581 "2019-07-20T11:23:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)\
**Post date:** [July 20, 2019, 11:23am UTC](https://discourse.julialang.org/t/some-unexplained-example-in-defining-concrete-type-from-an-abstract-type-with-multiple-parameters/26581/1 "2019-07-20T11:23:31Z")

</div>

Suppose I have a base type, which is abstract:  
`SuperType{T, S, T} = Tuple{T, S, T} where T <: Real where S <: AbstractString`

Indeed SuperType can be used for type assertion successfully:

```julia
(1.0, "hello", 1.0)::SuperType #> OK
(1.0, "hello", 1)::SuperType #> Error

```

Now I try to define a concrete type as a subtype of Supertype:  
`SubType = SuperType{Int, String, Int}`

But it fails:

> TypeError: in Type, in S, expected S\<:AbstractString, got Type{Int64}

I suspect this is somehow related to what are the innermost parameters and what are the outermost  
because of the following results:

Following is OK

```julia
Tuple2{S,T} = Tuple{S,T} where T<:Real where S<:String 
Tuple2{String, Int}

```

But following produces TypeError: in Type, in T, expected T\<:Real, got Type{String}

```julia
Tuple3{S,T} = Tuple{S,T} where S<:String where T<:Real 
Tuple3{String, Int}

```

I wonder what principle can explain all these behaviors coherently and how I define SubType as intended. It would be great if the document adds this corner case to improve understanding.

=============================================================================  
**EDIT:**  
I 've just realized what mistake I made. There are only two type variables T and S but I specified three in defining a concrete subtype. Also, although not explicitly stated in the document, it is evident by experiment that the innermost type variable should come first. So the correct way is

`SubType = SuperType{String, Int}`
