On Thu, Aug 11, 2016 at 8:52 PM, Stefan Kruger <[email protected]>
wrote:
> This surprised me:
>
> function hello(data::Array{AbstractString, 1})
> map(println, data)
> end
>
> julia> function hello(data::AbstractString)
> println(data)
> end
> hello (generic function with 1 method)
>
> julia> hello("hello")
> hello
>
> julia> function hello_array(data::Array{AbstractString, 1})
> map(println, data)
> end
> hello_array (generic function with 1 method)
>
> julia> hello_array(["Hello"])
> ERROR: MethodError: `hello_array` has no method matching
> hello_array(::Array{ASCIIString,1})
>
`T{A}` is not a subtype of `T{B}` even if `A<:B`
`hello{T<:AbstractString}(data::Array{T,1})`
>
> I had expected that Array{AbstractString, 1} meant "1-d array of anything
> string-like" and that passing an
> array of ASCIIString would qualify, but I must be missing something
> central.
>
> How would I declare a function parameter that is an array that can hold
> any string type?
>
> Many thanks for any pointers.
>
> Stefan
>