And to take that further, it's much better to use AbstractVector (with no parameters) in method defs as that can accept anything with the right shape.
On Wednesday, May 25, 2016, Stefan Karpinski <[email protected]> wrote: > Vector is the type you're looking for – the type which includes Vector{T} > for any T. Vector{Any} is a vector whose element type is `Any` > specifically, a much more specific type. We don't yet have a notation for > Vector{<:T} but it will likely be something like that. > > On Wed, May 25, 2016 at 8:08 AM, DNF <[email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote: > >> >> >> On Wednesday, May 25, 2016 at 11:50:43 AM UTC+2, DNF wrote: >>> >>> >>> This works, however, even though Vector is not a subtype of Vector{Any}: >>> >> goodbye(v::Vector) = println("bye, bye") >>> goodbye (generic function with 1 method) >>> >> goodbye([2,'a']) >>> bye, bye >>> >>> goodbye([2,2]) >>> bye, bye >>> >> >> This is a bit backwards. Vector{Any} is a subtype of Vector, of course! >> >> Perhaps I was expecting too much. I was envisioning a list containing >> 'any' sort of elements, and that would include vectors with all types of >> elements. After checking I see that numpy arrays are not a subclass of >> list, so Vector{Any} is sort of analogous to python 'list'. It just >> requires some extra thinking to realize that Vector{'anything'} is not >> included in that group. >> > >
