To answer myself: I didn't read the docs correctly. Or I got my types 
mangled. Or both.

The final splice should be
  splice!(a, 1:0, Vector{UInt8}[UInt8[7,3]])
not
  splice!(a, 1:0, UInt8[7,3])

splice! splices in another collection, not a single element.

Interfaces are very informally defined in Julia aren't they? I don't see 
there's any way to name an iterable something so that the def of splice! 
could be eg
  function splice!{E, T<:Integer}(a::Vector{E}, r::UnitRange{T}, 
ins::Iterable{E})
... which would have helped me not to trip over this problem

George


On Saturday, 23 July 2016 21:58:10 UTC+3, George Marrows wrote:
>
> Hi. As per the docs on splice! and n:(n-1) ranges, the following works 
> fine to insert a value before location 1 in a Vector:
> x = [1,2,3]
> splice!(x, 1:0, 23)
> print(x)  # => [23,1,2,3]
>
> But the following behaves strangely and seems to corrupt the array in the 
> process:
> a = Vector{UInt8}[UInt8[0xf3,0x32,0x37]]
> splice!(a, 1:0, UInt8[7,3])   # =>  MethodError: `convert` has no method 
> matching convert(::Type{Array{UInt8,1}}, ::UInt8)
> print(a) # => [#undef,#undef,UInt8[0xf3,0x32,0x37]]
>
> Is this a bug, or have I simply not read the docs correctly?
>
> Many thanks, 
> George
>

Reply via email to