You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When pattern-matching boolean values, it's common to match the true value first. However, this approach can lead to undesirable formatting behavior. For instance:
This:
switch (condition) {
|true=>()|false=>()
};
Formats to:
condition ?():();
Sometimes a code style when we first match a shorter branch (with less code) is preferred.
To prevent automatic formatting to a ternary expression in such cases we have to match false as a wildcard _false.
switch (condition) {
|true=>// short code()|_false=>// long code// long code// long code()
};
The text was updated successfully, but these errors were encountered:
denis-ok
changed the title
Pattern-matching of bool value formats to ternary if we match true first
Pattern-matching of bool value is formatted to ternary if we match true first
Jan 24, 2024
When pattern-matching boolean values, it's common to match the
true
value first. However, this approach can lead to undesirable formatting behavior. For instance:This:
Formats to:
Sometimes a code style when we first match a shorter branch (with less code) is preferred.
To prevent automatic formatting to a ternary expression in such cases we have to match
false
as a wildcard_false
.The text was updated successfully, but these errors were encountered: