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

Guide: array subscript notation #16447

Merged
merged 1 commit into from
Aug 21, 2014

Conversation

steveklabnik
Copy link
Member

Can't believe I forgot this!

println!("The second name is: {}", names[1]);
```

These subscripts start at zero, like in most programming langues, so the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/langues/languages/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uuuuuuugh thank you.

@bluss
Copy link
Member

bluss commented Aug 13, 2014

Maybe you did want to use Brian in the example. Just wondering :-)

@steveklabnik
Copy link
Member Author

: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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - "Brian"

Copy link
Member Author

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.

@EduardoBautista
Copy link
Contributor

Question, why is this in the "Strings" chapter?

@steveklabnik
Copy link
Member Author

Because git is strange. nice catch, this should have conflicted. fixing...

@steveklabnik
Copy link
Member Author

This is now good to go again.

@Gankra
Copy link
Contributor

Gankra commented Aug 18, 2014

Is it worth noting that subscripts also apply to many collections? e.g. let value = map[key].

@steveklabnik
Copy link
Member Author

No, because then we have to fully explain those.

@ftxqxd
Copy link
Contributor

ftxqxd commented Aug 20, 2014

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)?

@steveklabnik
Copy link
Member Author

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.

bors added a commit that referenced this pull request Aug 21, 2014
@bors bors closed this Aug 21, 2014
@bors bors merged commit 3f9ff2e into rust-lang:master Aug 21, 2014
@steveklabnik steveklabnik deleted the guide_vectors_extra branch October 25, 2017 18:26
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this pull request Feb 5, 2024
intenral: Cleanup error variants in MIR code a bit
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

Successfully merging this pull request may close these issues.

8 participants