Skip to content

Commit

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

Co-authored-by: Johnny Chen <johnnychen94@hotmail.com>
(cherry picked from commit 9c0e5b0d186ea95a06d5b0bdc4bc19d1a17b444d)
  • Loading branch information
ViralBShah authored and LilithHafner committed Mar 8, 2022
1 parent e27e485 commit 4700bd7
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 4700bd7

Please sign in to comment.