Control flow is one of the most important parts of Pureline.
Pureline standardizes clarity and structure, not identical syntax across languages. Java, JavaScript, TypeScript, and Go use explicit blocks for control flow. Languages with established readable shorthand, such as Crystal postfix guards, may use that shorthand when the condition and action remain simple.
Prefer Guard Clauses
if (request == null) {
return Result.empty();
}
if (!request.valid()) {
return Result.invalid();
}
var session = sessions.create(request.user());
return executor.execute(session, request); if (request != null) {
if (request.valid()) {
var session = sessions.create(request.user());
return executor.execute(session, request);
} else {
return Result.invalid();
}
}
return Result.empty(); The happy path should remain as close to the base indentation level as possible.
Avoid else
if (valid) {
execute();
} else {
reject();
} if (!valid) {
reject();
return;
}
execute(); var state = valid ? State.READY : State.INVALID; Complex nested ternaries are not Pureline.
Explicit Blocks in Brace-Based Languages
In Java, JavaScript, TypeScript, Go, and other brace-based languages, control-flow bodies use explicit blocks.
if (!valid) return; if (!valid)
return; if (!valid) {
return;
} The same principle applies to for, while, and comparable control-flow constructs.
This rule does not ban idiomatic shorthand in languages where that shorthand is a normal, readable part of the language. Crystal postfix guards such as return unless valid are Pureline-compliant when kept simple.