Skip to content

Commit

Permalink
Documentation: added example to the function hasfield. (From #41782) (#…
Browse files Browse the repository at this point in the history
…44274)

Co-authored-by: Johnny Chen <johnnychen94@hotmail.com>
(cherry picked from commit 9c0e5b0d186ea95a06d5b0bdc4bc19d1a17b444d)
(cherry picked from commit aa2421d)
  • Loading branch information
ViralBShah authored and KristofferC committed Mar 7, 2022
1 parent 596d31f commit 3f28e07
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3f28e07

Please sign in to comment.