-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
replace some occurrences of iteration over 1:length with more idiomatic structures (mostly eachindex) #55137
Conversation
…c structures (mostly eachindex)
Should probably be backported? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a pretty straightforward improvement, CI failures appear unrelated
@@ -978,7 +978,7 @@ end | |||
|
|||
Return an array with element type `T` (default `Int`) of the digits of `n` in the given | |||
base, optionally padded with zeros to a specified size. More significant digits are at | |||
higher indices, such that `n == sum(digits[k]*base^(k-1) for k=1:length(digits))`. | |||
higher indices, such that `n == sum(digits[k]*base^(k-1) for k in eachindex(digits))`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was clearer before since one is taking an exponential of k
. The genericness of iterating indices just takes away from the point being made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a reasonable position. OTOH, with 1:length, you have to worry about bounds errors which also distracts from the point. Personally, I think it's similar either way.
Not clear why this was removed from backport. Adding it back to 1.11 at least as it makes other things easier to backport. |
…ic structures (mostly eachindex) (JuliaLang#55137) Base should be a model for the ecosystem, and `eachindex(x)` is better than `1:length(x)` in almost all cases. I've updated many, but certainly not all examples. This is mostly a NFC, but also fixes JuliaLang#55136. (cherry picked from commit 0945b9d)
Base should be a model for the ecosystem, and
eachindex(x)
is better than1:length(x)
in almost all cases. I've updated many, but certainly not all examples. This is mostly a NFC, but also fixes #55136.