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

Contradiction between explanation and example about array assignment in manual #4727

Closed
nalimilan opened this issue Nov 4, 2013 · 1 comment
Labels
domain:docs This change adds or pertains to documentation

Comments

@nalimilan
Copy link
Member

In the manual, the documentation about array assignment says:

The size of X should be (length(I_1), length(I_2), ..., length(I_n)), and the value in location (i_1, i_2, ..., i_n) of A is overwritten with the value X[I_1[i_1], I_2[i_2], ..., I_n[i_n]].

http:https://docs.julialang.org/en/latest/manual/arrays/#assignment

But this "should" does not correspond to what is shown in the example:

julia> x = reshape(1:9, 3, 3)
3x3 Int64 Array
1 4 7
2 5 8
3 6 9

julia> x[1:2, 2:3] = -1
3x3 Int64 Array
1 -1 -1
2 -1 -1
3  6  9

Of course the reader understands that some sort of recycling takes place, but it would be good to state it explicitly when this applies. Also, "should" looks weird: either X has the correct dimensions, or it hasn't; either Julia does something with the value, or it triggers an error: "must" would be more appropriate.

@nalimilan
Copy link
Member Author

Cool, the new doc explains why I was getting unexpected results with boolean vectors! ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

1 participant