Testing if something is an instance of a class

At the moment, if I want to test: “Is v - which could be anything - an instance of class V?” then I do:

if type(v) == "table" and v.is_a and v:is_a(V) then
    -- is what I want
else
   -- is not
end

Is this the right/best way to do it? Is there anything I’ve missed here?

I’m doing this often enough that I’m going to wrap it up into a function so thought I’d ask before baking it.

I don’t see any short cut, you have to verify each single part of the construct in order to prevent a possible failure of the next one.

Well, that doesn’t mean there is no short cut, but take it as a positive answer anyway.