The answers of Sven and John are both perfectly correct. If you donβt want to enter method type parameters, as Johnβs code does, you can use the
eltype function:
julia> d = ["foo"=>1, "bar"=>2] ["foo"=>1,"bar"=>2] julia> eltype(d) (ASCIIString,Int64) julia> eltype(d)[1] ASCIIString (constructor with 1 method) julia> eltype(d)[2] Int64 julia> eltype(keys(d)) ASCIIString (constructor with 1 method) julia> eltype(values(d)) Int64
As you can see, there are several ways to hide this cat, but I think that eltype(keys(d)) and eltype(values(d)) by far the clearest, and since the keys and values functions simply return immutable objects of the form , the compiler is smart enough not to actually create any objects.
source share