Skip to content

Add boolean operator guidance to Elixir usage rules#6625

Closed
Vitaly-A-Ivanov wants to merge 1 commit intophoenixframework:mainfrom
Vitaly-A-Ivanov:elixir-md-extra-rule
Closed

Add boolean operator guidance to Elixir usage rules#6625
Vitaly-A-Ivanov wants to merge 1 commit intophoenixframework:mainfrom
Vitaly-A-Ivanov:elixir-md-extra-rule

Conversation

@Vitaly-A-Ivanov
Copy link
Copy Markdown

Summary

Adds guidance to usage-rules/elixir.md for choosing && / || versus and / or.

What changed

  • explains why && and || are usually safer in Elixir
  • documents when and and or are still appropriate
  • adds examples covering structs, nil, and changeset/database-style flows

Why

Elixir’s and and or require a boolean left-hand side, which can raise when used with values like structs or nil. This rule makes that distinction explicit and gives contributors a consistent default.

Notes

  • docs-only change
  • no runtime or test changes

@Vitaly-A-Ivanov
Copy link
Copy Markdown
Author

Added this to make the and/or vs &&/|| distinction explicit in the Elixir usage rules, with examples for the common nil/struct case. Happy to adjust the wording or trim the examples if you’d prefer it shorter.

@josevalim
Copy link
Copy Markdown
Member

Thank you but our general guidance with the AGENTS.md is that we only add rules that the Phoenix team runs into. This is because if we were to collect everyone's input, even though they are appreciated, they would quickly run out of control.

As most things generated by Phoenix, they are a starting point, so please expand them based on your needs! Thanks!

@josevalim josevalim closed this Mar 17, 2026
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.

2 participants