Skip to content

[style-guide] prefer leading rather than trailing operators #687

@smoothdeveloper

Description

@smoothdeveloper

This is a suggestion regarding position of operators in chained expressions

starting from:

if
    long-thing &&
    another-long-thing  &&
    another-long-thing &&
    another-long-thing
then

I generally feel it is actually better (especially with long things) to put the operator in a leading position on the next line:

if
    long-thing
    && another-long-thing
    && another-long-thing
    && another-long-thing
then

The same rule could be extended for , as well.

let a =
    long-thing,
    another-long-thing,
    another-long-thing
let a =
    long-thing
    , another-long-thing
    , another-long-thing

Note that F# users tend to use |> operator in such manner.

Also, most languages using "fluent notation" (chaining method calls), would put the . operator in leading position of next line

a
    .Something()
    .AnotherThing()

I've consistently felt it is more readable, easier to extend code, in many languages, using this type of positioning.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions