... should actually be written using pattern-matching:
{ok, A} = a()
The maybe statement is unnecessary and the only difference between the two is that the exception raised in the case of error changes from else_clause to badmatch.
If an else_clause is present, though, the rule should not be applied.
Should be on by default?
YES
Options
None.
Reasoning
Single-pattern maybe blocks may be written more concisely or removed entirely.
No Single Clause Maybe Statements
Brief Description
The following code...
... should actually be written using pattern-matching:
The
maybe
statement is unnecessary and the only difference between the two is that the exception raised in the case of error changes fromelse_clause
tobadmatch
.If an
else_clause
is present, though, the rule should not be applied.Should be on by default?
YES
Options
Reasoning
Single-pattern
maybe
blocks may be written more concisely or removed entirely.Origin
Inspired by #290.