type Tech
cl::Array{Float64,1}
function Tech()
this = new()
this.cl=[1:4]
this
end
end
tech = Tech()
How can I check if tech.asf is not a valid field?
Hi,
you could look up the name in the list of fieldnames:
in(:asf, names(Tech))
will return true if Tech has a field "asf", false otherwise.
I don't know what your usage scenario is, but perhaps a Dict() might be an
alternative, where you can set arbitrary fields and query their existence wi
It seems names() is deprecated now and fieldnames() is preferable.
type myType
a
b
c
end
fields = ["a","B","c","d"] #field names to test
for f in fields
println( in(symbol(f), fieldnames(myType)))
end