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

add Base.hasproperty? #28850

Closed
stevengj opened this issue Aug 23, 2018 · 2 comments

Comments

@stevengj
Copy link
Member

commented Aug 23, 2018

I just realized that we don't have a hasproperty(x, s) function, analogous to haskey. We could define one with the default definition:

hasproperty(x, s::Symbol) = s in propertynames(x)

This came up in https://github.com/JuliaPy/PyCall.jl/pull/517/files#r212317623

@ararslan

This comment has been minimized.

Copy link
Member

commented Aug 23, 2018

Relatedly, a hasfield function to accompany getfield/setfield! may be nice. This definition actually works for that:

hasfield(T::DataType, name::Symbol) = fieldindex(T, name, false) > 0
@vtjnash

This comment has been minimized.

Copy link
Member

commented Aug 23, 2018

Agreed. I think the fallback may be isdefined though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.