The Queue constructor (like all collection constructors) takes a collection
which it iterates over and converts each value it gets to the expected
element type – in this case ByteString. If you iterate over "1234" you get
'1' then '2' then '3' then '4' – each of which is converted to a string and
then inserted into your queue.

On Thu, Feb 4, 2016 at 4:29 PM, Michael Landis <darkskyanar...@gmail.com>
wrote:

> DataStructures.Queue is doing strange things for me.
>
> Can someone please post proper syntax for forward declarations of an empty
> Queue{ByteString} and maybe an in-line instantiation (if different) so I
> can be sure that I am getting the declarations right?
>
> When I do:
> using DataStructures;
> qbs = Queue{ByteString}()      # --> convert errors
> qbs = Queue{ByteString}(0)    # --> convert errors
> qbs = Queue{ByteString}("")   # --> no errors, so ok?
> typeof(qbs)                              # -->
> DataStructures.Queue{ByteString}      (so far, so good)
> length(qbs)                              # --> 0 (hmmm)
> # which seems ok, but ...
> qbs = Queue{ByteString}("1234")   # ok
> typeof(qbs)                                      # -->
> DataStructures.Queue{ByteString}
> length(qbs)                                      # --> 4 ??? why not 1?
> enqueue!(qbs, "xyz")                       # --> MethodError: `push!` has
> no method matching push!(::ASCIIString, ::ASCIIString ) in queue.jl:17
> x = dequeue!( qbs )                         # --> MethodError: `shift!`
> has no method matching shift!(::ASCIIString) in ... dequeue! at queue.jl:21
>
> so... I am growing increasingly mystified.  How can the type be right when
> you ask for it, but wrong when you use it?  Maybe I'm declaring it wrong?
> Any insight or suggestions would be appreciated.
>

Reply via email to