Skip to content
Discussion options

You must be logged in to vote

Quick replace patterns
Replace A && B && C with all[A, B, C]

Replace A || B || C with any[A, B, C]

Convert mixed precedence by nesting: A && (B || C) -> all[A, any[B, C]]

Negation examples: !(any[X, Y]) -> not any[X, Y] or all[not X, not Y] depending on intent

Examples
Validation

Old: if (name != "" && age >= 0 && age <= 120) {

New: if all[name != "", age >= 0, age <= 120] {

Mixed logic

Old: if (isAdmin || (isOwner && isActive)) {

New: if any[isAdmin, all[isOwner, isActive]] {

Tooling and automation
Add an automated codemod that:

Converts simple chains of && to all[...] and || to any[...]

Detects mixed chains and either nests or flags for manual review

Provide editor snippets for single-l…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@DanexCodr
Comment options

@DanexCodr
Comment options

Answer selected by DanexCodr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General General topics and discussions that don't fit into other categories, but are related to GitHub Show & Tell Discussions where community members share their projects, experiments, or accomplishments
2 participants