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

[Edit] C++: maps #6528

Merged
merged 8 commits into from
Apr 13, 2025
Merged

[Edit] C++: maps #6528

merged 8 commits into from
Apr 13, 2025

Conversation

mamtawardhani
Copy link
Collaborator

Description

[Edit] C++: maps

Issue Solved

Closes #6469

Type of Change

  • Editing an existing entry (fixing a typo, bug, issues, etc)

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@mamtawardhani mamtawardhani added enhancement New feature or request c++ C++ entries labels Apr 11, 2025
@dakshdeepHERE dakshdeepHERE self-assigned this Apr 11, 2025
@dakshdeepHERE dakshdeepHERE added the status: under review Issue or PR is currently being reviewed label Apr 11, 2025
}
```

## 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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Collaborator

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

Copy link
Collaborator Author

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

Copy link
Collaborator

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
Copy link
Collaborator

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.

Copy link
Collaborator Author

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"

Copy link
Collaborator

@dakshdeepHERE dakshdeepHERE left a 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

@mamtawardhani
Copy link
Collaborator Author

This is fixed @dakshdeepHERE 🚀

Copy link
Collaborator

@dakshdeepHERE dakshdeepHERE left a comment

Choose a reason for hiding this comment

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

LGTM

@dakshdeepHERE dakshdeepHERE merged commit 27a91bb into Codecademy:main Apr 13, 2025
7 checks passed
Copy link

👋 @mamtawardhani
You have contributed to Codecademy Docs, and we would like to know more about you and your experience.
Please take a minute to fill out this four question survey to help us better understand Docs contributions and how we can improve the experience for you and our learners.
Thank you for your help!

🎉 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.
If you're appearing as anonymous and want to be credited, visit the linked accounts page and ensure that your GitHub account is linked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Edit] C++: maps
2 participants