First sentence should have been:

A Dict{ASCIIString, Any}, is not a subtype off Dict{AbstractString, Any}.

On Thursday, January 7, 2016 at 6:50:54 PM UTC+1, Kristoffer Carlsson wrote:
>
> A Dict{AbstractString, Any}, is not a subtype off Dict{AbstractString, 
> Any}. You can read more about why and how here: 
> https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)
> and 
> http://docs.julialang.org/en/release-0.4/manual/types/#man-parametric-types
>
> You need something like:
>
> function ma{S <: AbstractString}(s1::AbstractString, ad::Array{Dict{S,Any
> }})
>          return (s1, ad)
>        end
>
>
> On Thursday, January 7, 2016 at 6:40:34 PM UTC+1, Marco Caramma wrote:
>>
>> Hi, I'm having trubles understanding why the following code generate 
>> 'method matching' errors.
>>
>> In my understanding this 2 signatures should be compatibles:
>>
>>     function signature =>(::AbstractString, ::Array{Dict{AbstractString,
>> Any},N})
>>     call signature =>(::ASCIIString, ::Array{Dict{ASCIIString,Any},1})
>>
>> This repl session show the problem:
>>
>> julia> function ma(s1::AbstractString, ad::Array{Dict{AbstractString,Any
>> }})
>>          return (s1, ad)
>>        end
>> ma (generic function with 1 method)
>>
>>
>> julia> function a(s1::AbstractString, s2::AbstractString, s3::
>> AbstractString, b1::Bool)
>>          return ma(s1, [Dict("s2"=>s2, "s3"=>s3, "b1"=>b1)])
>>        end
>> a (generic function with 1 method)
>>
>>
>> julia> ma("s1",[Dict("s2"=>"s2","s3"=>"s3","b1"=>true)])
>> ERROR: MethodError: `ma` has no method matching ma(::ASCIIString, ::Array
>> {Dict{ASCIIString,Any},1})
>> Closest candidates are:
>>   ma(::AbstractString, ::Array{Dict{AbstractString,Any},N})
>>
>>
>> julia> a("s1","s2","s3", true)
>> ERROR: MethodError: `ma` has no method matching ma(::ASCIIString, ::Array
>> {Dict{ASCIIString,Any},1})
>> Closest candidates are:
>>   ma(::AbstractString, ::Array{Dict{AbstractString,Any},N})
>>  in a at ./none:2
>>
>>
>> NOTE: I'm new to Julia and I usually try to figure things out by miself 
>> but this time I can't really see the light.
>>
>

Reply via email to