Skip to content

docs: enhance non-assertive map access anti-pattern documentation #14501

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

Merged

Conversation

abreujp
Copy link
Contributor

@abreujp abreujp commented May 17, 2025

  • Add comparison table for access notations
  • Improve explanations with clearer examples
  • Add example of error propagation
  • Include guidance for when to use each access method
  • Format examples for better readability

- Add comparison table for access notations
- Improve explanations with clearer examples
- Add example of error propagation
- Include guidance for when to use each access method
- Format examples for better readability
- Add "Map is `nil`" column to map access table
- Include Map.get and Map.fetch! access methods
- Combine error propagation examples
- Add summary section on pattern-matching
@abreujp
Copy link
Contributor Author

abreujp commented May 19, 2025

Thank you @sabiwara for your valuable feedback!

I've updated the pull request with all your suggested changes:

  1. Added a "Map is nil" column to the table showing behavior when the map itself is nil
  2. Added rows for Map.get(map, :key) (required map, optional key) and Map.fetch!(map, "key") (support for non-atom keys)
  3. Combined the error propagation example with the bad_point example, with an adapted explanation
  4. Added a summary section at the end of the explanation that recaps the different access methods, including pattern-matching

I'm new to open source contributions and still learning the best practices, so I truly appreciate your detailed review. Your guidance helps me improve both the documentation and my understanding of how to contribute effectively.

Let me know if you'd like any further adjustments!

@josevalim
Copy link
Member

Thank you @abreujp! I have submitted some changes to remove the duplication and streamline it. If you are happy with it, let me know and I will merge it!

@abreujp
Copy link
Contributor Author

abreujp commented May 20, 2025

Yes, I agree, thank you. @josevalim

@josevalim josevalim merged commit 30d1968 into elixir-lang:main May 20, 2025
1 check passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@abreujp abreujp deleted the improve-non-assertive-map-access-doc branch May 20, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants