diff --git a/base/reflection.jl b/base/reflection.jl index bf8ceabe1f39b..5490cae9511c8 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -194,8 +194,23 @@ fieldnames(t::Type{<:Tuple}) = ntuple(identity, fieldcount(t)) Return a boolean indicating whether `T` has `name` as one of its own fields. +See also [`fieldnames`](@ref), [`fieldcount`](@ref), [`hasproperty`](@ref). + !!! compat "Julia 1.2" This function requires at least Julia 1.2. + +# Examples +```jldoctest +julia> struct Foo + bar::Int + end + +julia> hasfield(Foo, :bar) +true + +julia> hasfield(Foo, :x) +false +``` """ function hasfield(T::Type, name::Symbol) @_pure_meta