Skip to content

Inconsistent array initialization with space and semicolon #20957

@mprat

Description

@mprat

In Julia 0.5.0 array initialization is inconsistent when using spaces and semicolons.

julia> [1;2;3]
3-element Array{Int64,1}:
 1
 2
 3

Creates a 3-element rather than a 3x1 array. But, adding a space makes a 3x2 array:

julia> [[1;2;3] [4;5;6]]
3×2 Array{Int64,2}:
 1  4
 2  5
 3  6

Spaces add a second dimension and semicolons add rows, except for the [1;2;3] case.

julia> [1 2 3]
1×3 Array{Int64,2}:
 1  2  3

julia> [1 2 3]'
3×1 Array{Int64,2}:
 1
 2
 3

julia> [1 2 3; 4 5 6]
2×3 Array{Int64,2}:
 1  2  3
 4  5  6

Making initialization consistent so that a semicolon adds a row (i.e. [1;2;3] initialization creates a 3x1 array) makes array initialization more consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions