Is this what you're looking for?
julia> yyy(x::DataType) = true yyy (generic function with 1 method) julia> yyy(x) = false yyy (generic function with 2 methods) julia> yyy(Int) true julia> yyy(5) false On Thursday, April 30, 2015 at 11:04:02 AM UTC-4, Tamas Papp wrote: > > This is toy problem that came up in the context of something larger, > reduced to be simple so that I can ask about it more easily. > > Suppose I want to implement the function > > is_instanceof_datatype(x) = is(typeof(x),DataType) > > using dispatch: a default method that is > > is_instanceof_datatype(x) = false > > and some other method which only gets called when x is an instance of a > DataType: > > is_instanceof_datatype{ ... }(x::T) = true # how to dispatch > > but I don't know how to do the latter, hence the .... > > The context is that I want to write a method that, for instances of > DataTypes, returns the slots in a given order, but for other values it > does something else, and I don't know how to do this. > > Best, > > Tamas >