isgeneric
isgeneric(f::Function) -> Bool
Determine whether a Function
is generic.
Examples
julia> isgeneric(sum)
true
julia> function add(a, b)
return a + b
end
julia> isgeneric(add)
false
julia> struct Person
name::String
age::Int
end
julia> isgeneric(Person)
false
julia> isgeneric(+)
true
Common mistake example:
julia> isgeneric(5)
ERROR: MethodError: no method matching isgeneric(::Int64)
In this example, the isgeneric
function is applied to a non-function type (Int64
). Remember that isgeneric
is meant to check if a given object is a generic function, so it should be used with function objects.
See Also
assert, backtrace, code_llvm, code_lowered, code_native, code_typed, code_warntype, :@which, compilecache, current_module, eval, finalize, finalizer, fullname, function_module, function_name, include_dependency, InterruptException, invoke, isconst, isdefined, isgeneric, methodswith, method_exists, module_name, module_parent, require, subtypes, unsafe_load, workspace, __precompile__,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.