-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Guide: array subscript notation #16447
Conversation
println!("The second name is: {}", names[1]); | ||
``` | ||
|
||
These subscripts start at zero, like in most programming langues, so the |
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.
s/langues/languages/
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.
uuuuuuugh thank you.
Maybe you did want to use Brian in the example. Just wondering :-) |
:embarassed: |
|
||
These subscripts start at zero, like in most programming languages, so the | ||
first name is `names[0]` and the second name is `names[1]`. The above example | ||
prints `The second name is Bryan`. |
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.
typo - "Brian"
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.
lol, was hoping you wouldn't see :embarassed:
Fixing now.
Question, why is this in the "Strings" chapter? |
Because |
This is now good to go again. |
Is it worth noting that subscripts also apply to many collections? e.g. |
No, because then we have to fully explain those. |
Should this also mention what happens with out-of-bounds indices? And perhaps that indices must always be non-negative (because e.g. in Python, negative indices index from the end)? |
I don't think so, because we haven't talked about task failure at all, and it's quite easy to try yourself and see what happens. Additionally, we don't need to pre-emptively say that Rust doesn't have some feature, either. Remember, this guide isn't comprehensive, it's an introduction. |
intenral: Cleanup error variants in MIR code a bit
Can't believe I forgot this!