# Check head of an expression

**URL:** <https://discourse.julialang.org/t/check-head-of-an-expression/48852>\
**Category:** General Usage\
**Tags:** metaprogramming\
**Created:** [October 23, 2020, 12:30am UTC](https://discourse.julialang.org/t/check-head-of-an-expression/48852 "2020-10-23T00:30:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 23, 2020, 12:30am UTC](https://discourse.julialang.org/t/check-head-of-an-expression/48852/1 "2020-10-23T00:30:30Z")

</div>

I Often have an expression

```julia
t = :(y = f(:x))

```

I want to examine the head of the RHS, I can do this by looking at

```julia
rhs = t.args[2]
rhs.head ...

```

Unfortunately, if you have

```julia
t = :(y = :x))

```

then `rhs` is a `QuoteNode` and I get the error `type QuoteNode has no field head`.

I feel like I’ve seen solutions to this problem elsewhere, but they may have disappeared into the slack hole. Is there an idiom for checking the `head` of something that could be an expression but could also be a `QuoteNode`. I just want it to return `false` when it sees a `QuoteNode`.

I know this is a one liner but i remember a single commonly used function or solution somewhere.

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [October 23, 2020, 7:22am UTC](https://discourse.julialang.org/t/check-head-of-an-expression/48852/2 "2020-10-23T07:22:00Z")

</div>

I think you are looking for `Meta.isexpr`.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 23, 2020, 12:39pm UTC](https://discourse.julialang.org/t/check-head-of-an-expression/48852/3 "2020-10-23T12:39:08Z")

</div>

Thanks! This is exactly it!
