Check head of an expression

I Often have an expression

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

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

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

Unfortunately, if you have

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.

I think you are looking for Meta.isexpr.


Thanks! This is exactly it!