-
Notifications
You must be signed in to change notification settings - Fork 3.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
[Edit] C++: maps #6528
[Edit] C++: maps #6528
Conversation
content/cpp/concepts/maps/maps.md
Outdated
} | ||
``` | ||
|
||
## Accessing Elements | ||
This code creates a map that associates names (strings) with ages (integers). It demonstrates three different ways to insert elements into a map: using the subscript operator `[]`, using the [`.insert()`](https://www.codecademy.com/resources/docs/cpp/maps/insert) method with a `pair`, and using `.insert()` with an initializer list. |
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 code creates a map that associates names (strings) with ages (integers). It demonstrates three different ways to insert elements into a map: using the subscript operator `[]`, using the [`.insert()`](https://www.codecademy.com/resources/docs/cpp/maps/insert) method with a `pair`, and using `.insert()` with an initializer list. | |
This code creates a map that associates `names` (strings) with `ages` (integers). It demonstrates three different ways to insert elements into a map: using the subscript operator `[]`, using the [`.insert()`](https://www.codecademy.com/resources/docs/cpp/maps/insert) method with a `pair`, and using `.insert()` with an initializer list. |
Let's move these under quotations as these are present inside the code
``` | ||
1. Using the subscript operator `[]` - simple but creates a new element if the key doesn't exist. | ||
2. Using the `.at()` method - throws an exception if the key isn't found. | ||
3. Using the `.find()` method - returns an iterator that you can check. |
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.
Let's link this here
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.
the term find() is linked already in line 40, should we link it again? @dakshdeepHERE
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.
@mamtawardhani oh really then there's no need :)
|
||
Note that the elements are always sorted by key (alphabetically in this case). | ||
|
||
## Frequently Asked Questions |
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.
In other PR we were using the heading as just FAQ
and here its the full form let's keep it same across all the entries.
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.
Yeah, so this was a recent update by Devansh - it should be "Frequently Asked Questions"
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.
Few comments from my side
This is fixed @dakshdeepHERE 🚀 |
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.
LGTM
👋 @mamtawardhani 🎉 Your contribution(s) can be seen here: https://www.codecademy.com/resources/docs/cpp/maps Please note it may take a little while for changes to become visible. |
Description
[Edit] C++: maps
Issue Solved
Closes #6469
Type of Change
Checklist
main
branch.Issues Solved
section.