# What is the right usage of where clauses to avoid these function calls?

**URL:** <https://discourse.julialang.org/t/what-is-the-right-usage-of-where-clauses-to-avoid-these-function-calls/37812>\
**Category:** General Usage\
**Tags:** parametric-types\
**Created:** [April 18, 2020, 6:31pm UTC](https://discourse.julialang.org/t/what-is-the-right-usage-of-where-clauses-to-avoid-these-function-calls/37812 "2020-04-18T18:31:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdubya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdubya/32/394_2.png) [@pdubya](https://discourse.julialang.org/u/pdubya)\
**Post date:** [April 18, 2020, 6:31pm UTC](https://discourse.julialang.org/t/what-is-the-right-usage-of-where-clauses-to-avoid-these-function-calls/37812/1 "2020-04-18T18:31:21Z")

</div>

Hi all,  
Trying to write a function to extract one of the type parameters from the instance of a struct. Have it working but wondering what the syntax would be to this in one line as opposed to using the Type{…} function that I’ve implemented.

```julia
struct A{X} end

struct B{U <: A, T <: Real}
    val::T
end

struct C{V <: B}
    val::B
end

# why won't b = B{A{:foo}}(32.6) suffice?? Not clear, but mostly orthogonal to question
b = B{A{:foo}, Float64}(32.6)
c = C{B{A{:foo}, Float64}}(b)

# **given object of type C how do you find U?**
flavor(::Type{B{X, T}} where T) where X = X
flavor(::C{R}) where R = flavor(R)
# what is the equivalent one-liner? below doesn't work
# flavor(::C{R{S}}) where R where S = S

```

thanks in advance

---

<div class="post-metadata">

**Author:** ![jbrea](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbrea/32/3879_2.png) [@jbrea](https://discourse.julialang.org/u/jbrea)\
**Post date:** [April 18, 2020, 6:58pm UTC](https://discourse.julialang.org/t/what-is-the-right-usage-of-where-clauses-to-avoid-these-function-calls/37812/2 "2020-04-18T18:58:34Z")

</div>

Are you looking for `flavor(::C{<:B{S}}) where S = S`?

---

<div class="post-metadata">

**Author:** ![pdubya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdubya/32/394_2.png) [@pdubya](https://discourse.julialang.org/u/pdubya)\
**Post date:** [April 18, 2020, 8:39pm UTC](https://discourse.julialang.org/t/what-is-the-right-usage-of-where-clauses-to-avoid-these-function-calls/37812/3 "2020-04-18T20:39:36Z")

</div>

looks good, thank you.
