I understand the difference between the UnitRange and Array/Vector types. I sort of get the syntax for stacking two ranges and converting them into a vector using ; and [] as in
But I think I need some hint on how to remember/understand/interpret the usage of semicolon for converting just a single unit range into a vector as in:
semicolons separate statements, begin a list of keyword arguments in function declarations or calls, or are used to separate array literals for vertical concatenation
and I am just not able to fit this usage to the above described conversion of a range into a vector.
I don’t see how “with nothing” is a useful concept here. You can concatenate any number of abstract vectors into a vector, any number includes 1 and 0.
Perhaps I am just too biased to see the semicolon as a separator of two things. That is why I somehow easily accepted the syntax [a;b] and struggled mentally with [a;]. But most probably there is not much more to dig here. I will just remember it. Thanks.
Yes instead of separators I think it’s best to think of [a, b, ...], [a; b; ...], [a b ...] and [a b; c d; ...] as fancy syntax for four different functions.
Four lines above in your linked documentation page, there’s a description specifically for the case of array literals:
The vcat function concatenates arrays vertically. Here “array” means any subtype of AbstractArray (other types are treated as single-element arrays). And a range such as 1:3 is an AbstractArray:
julia> supertypes(typeof(1:3))
(UnitRange{Int64}, AbstractUnitRange{Int64}, OrdinalRange{Int64, Int64},
AbstractRange{Int64}, AbstractVector{Int64}, Any)
julia> AbstractVector
AbstractVector{T} where T (alias for AbstractArray{T, 1} where T)
So that’s why the 1:3 range gets “flattened” into three values in the resulting vector.
(As for the remaining cases: [a b ...] is fancy syntax for hcat and [a b ...; c d ...; ...] is fancy syntax for hvcat. Both of these also treat their arguments as iterators.)