Byte array puzzle

When wrapping byte arrays in square brackets, Julia thinks it’s an array inside an array but only when there’s no semicolon. Interesting… What gives?

julia> b"\x01\x02"
2-element Array{UInt8,1}:
 0x01
 0x02

julia> [b"\x01\x02"]
1-element Array{Array{UInt8,1},1}:
 UInt8[0x01, 0x02]

julia> [b"\x01\x02" ;]
2-element Array{UInt8,1}:
 0x01
 0x02

julia> @which [[1];]
vcat(arrays::Array{T,1}...) where T in Base at array.jl:1411
1 Like

Or to be more explicit: the semicolon triggers the concatenation of all the entries in its arguments. That’s not specific to byte arrays.