Le samedi 28 mars 2015 à 21:35 -0700, Philip Tellis a écrit :
> I've written the following code:
> 
> 
> 
> import Base.convert
> function convert(::Type{UTF8String}, x::Int64)
>     return utf8(string(x))
> end
> println(convert(UTF8String, 10))
> println(convert(Array{UTF8String, 1}, [10]))
> 
> 
> 
> The intent is to convert an Array of Int64 into an Array of
> UTF8String.
> 
> 
> The first println works correctly and converts 10 into "10"
> 
> 
> The second println should print an array of ["10"], but instead gives
> me the following error:
> 
> 
> type: arrayset: expected UTF8String, got ASCIIString
> while loading In[41], in expression starting on line 6
> 
>  in copy! at abstractarray.jl:149
>  in convert at array.jl:220
> 
> 
> I'm using Julia 0.3.6
> 
> 
> Any idea on what I'm doing wrong?
This works perfectly fine for me with 0.3.6 on Linux. Could you try at
the Julia-REPL instead of IJulia (as you appear to be using). Can you
post the output of versioninfo()?


(FWIW, I'm not sure what you're trying to do is a great idea. convert is
not defined that way because moving between numbers and strings is not
considered a mere conversion, i.e. it should never happen automatically.
Better give that function a different name, or use map() or a
comprehension.)


Regards

Reply via email to