Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: added example to the function hasfield. #41782

Closed
wants to merge 4 commits into from

Conversation

ignace-computing
Copy link

If this change is too absurd, please ignore it.
However, I believe it might help new users (like myself) to write Julia programs more easily.

If this change is too absurd, please ignore it. However I believe it might help new users (like myself) to write Julia programs more easily.
base/reflection.jl Outdated Show resolved Hide resolved
Co-authored-by: Thomas Christensen <[email protected]>
base/reflection.jl Outdated Show resolved Hide resolved
@mcabbott
Copy link
Contributor

mcabbott commented Aug 4, 2021

Might it be worth pointing out how this behaves on abstract types? If I understand right false means "I couldn't prove that such a field always exists", not that it never exists.

julia> Ref("bar").x
"bar"

julia> hasfield(Ref, :x)
false

julia> fieldnames(Ref)
ERROR: ArgumentError: type does not have a definite number of fields

julia> hasfield(Base.RefValue, :x)
true

julia> fieldnames(Base.RefValue)
(:x,)

Possibly in words, instead of an example? Just to make clear that it's not name in fieldnames(T).

Also, it might be worth adding a line like:

See also fieldnames, fieldcount, hasproperty

@ViralBShah
Copy link
Member

Let's get this rebased and address the comments (or alternatively close).

@kshyatt kshyatt added the docs This change adds or pertains to documentation label Nov 16, 2021
@ViralBShah ViralBShah closed this Feb 20, 2022
aviatesk pushed a commit that referenced this pull request Feb 23, 2022
…44274)

Co-authored-by: Johnny Chen <[email protected]>
(cherry picked from commit 9c0e5b0d186ea95a06d5b0bdc4bc19d1a17b444d)
staticfloat pushed a commit to JuliaCI/julia-buildkite-testing that referenced this pull request Mar 2, 2022
…g#41782) (JuliaLang#44274)

Co-authored-by: Johnny Chen <[email protected]>
(cherry picked from commit 9c0e5b0d186ea95a06d5b0bdc4bc19d1a17b444d)
KristofferC pushed a commit that referenced this pull request Mar 3, 2022
…44274)

Co-authored-by: Johnny Chen <[email protected]>
(cherry picked from commit 9c0e5b0d186ea95a06d5b0bdc4bc19d1a17b444d)
(cherry picked from commit aa2421d)
KristofferC pushed a commit that referenced this pull request Mar 7, 2022
…44274)

Co-authored-by: Johnny Chen <[email protected]>
(cherry picked from commit 9c0e5b0d186ea95a06d5b0bdc4bc19d1a17b444d)
(cherry picked from commit aa2421d)
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
…g#41782) (JuliaLang#44274)

Co-authored-by: Johnny Chen <[email protected]>
(cherry picked from commit 9c0e5b0d186ea95a06d5b0bdc4bc19d1a17b444d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants