Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency converting multi-dimensional array literals #5763

Closed
ssfrr opened this issue Feb 11, 2014 · 3 comments
Closed

Inconsistency converting multi-dimensional array literals #5763

ssfrr opened this issue Feb 11, 2014 · 3 comments

Comments

@ssfrr
Copy link
Contributor

ssfrr commented Feb 11, 2014

It looks like these two 2D array literals produce the same array, but when prepending the 2nd syntax with Float32 to force the type I get a conversion error.

julia version 0.3.0-prerelease+604

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

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

julia> Float32[1 2 3; 3 4 5]
2x3 Array{Float32,2}:
 1.0  2.0  3.0
 3.0  4.0  5.0

julia> Float32[[1 2 3]; [3 4 5]]
ERROR: no method convert(Type{Float32}, Array{Int64,2})
 in setindex! at array.jl:413
 in getindex at array.jl:153
@simonster
Copy link
Member

Somewhat related to #3737

@JeffBezanson
Copy link
Sponsor Member

The problem is that [ ] performs concatenation of arrays, while T[] constructs arrays where every element is of type T, and no concatenation is done. Most of us want to get farther from the concatenating behavior, but I'm not sure what T[a; b] should do.

@JeffBezanson
Copy link
Sponsor Member

Closing as dup of #3737.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants