Firstly, instead of using ```symbol("is_continuous")``` you can use the
colon notation ```:is_continuous```. Secondly, you can do element wise
comparison by using ```.==``` operator. This will return a BitArray. You
can then find where the BitArray is true by using the ```find``` function
which returns an array of indices.
So for your case all you would need to do is
```
index = find(fn .== :is_continuous)
```
On Wednesday, September 9, 2015 at 6:01:47 PM UTC-7, J Luis wrote:
>
> So I need to find position of a certain type member in a type. Easy, I
> though
>
> julia> fn = fieldnames(GMT_PALETTE)
> 9-element Array{Symbol,1}:
> :n_headers
> :n_colors
> :alloc_level
> :auto_scale
> :model
> :is_gray
> :is_bw
> :is_continuous
> :z_unit_to_meter
>
> julia> search(fn,"is_continuous")
> ERROR: MethodError: `search` has no method matching
> search(::Array{Symbol,1}, ::ASCIIString)
> Closest candidates are:
> search(::AbstractString, ::AbstractString)
> search(::AbstractString, ::AbstractString, ::Integer)
>
> Went to the docs and found the "symbol" function and though, ok now it
> will work
>
> julia> search(fn,symbol("is_continuous"))
> ERROR: MethodError: `search` has no method matching
> search(::Array{Symbol,1}, ::Symbol)
>
> Ok, I can do a loop over the number of elements and ask
>
> fn[k] == symbol("is_continuous")
>
> but isn't there a more compact way of do this ?
>
> (I confess this parts of Julia are annoying)
>
> Thanks
>