Checking if variable is a type of number

If I want to check if a variable is a number what is a succinct way to do this?

For example I can do something like:

if typeof(x) == Int64 || typeof(x) == Float64
    #do something
else

But the above wouldn’t capture other types of Integers or Floats, e.g. Float32, etc.

Thank you for the help!

Instead of checking for specific types (Int64, Float64), check for the supertype:

if x isa Number
    #do something
else
9 Likes