Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ternaries should be multi-line with indents #127

Open
brekk opened this issue Feb 8, 2024 · 0 comments
Open

Ternaries should be multi-line with indents #127

brekk opened this issue Feb 8, 2024 · 0 comments

Comments

@brekk
Copy link
Contributor

brekk commented Feb 8, 2024

I have code like this:

collatzStep :: Integer -> Integer
collatzStep = (x) => (Math.mod(x, 2) != 0 ? 3 * x + 1 : toInteger(x / 2))

collatz :: Integer -> List Integer
collatz = (step) => (step == 1 ? [1] : [step, ...collatz(collatzStep(step))])

And if possible I'd like for the auto-formatter to make it look like this instead:

collatzStep :: Integer -> Integer
collatzStep = (x) => (
  Math.mod(x, 2) != 0
    ? 3 * x + 1
    : toInteger(x / 2)
)

collatz :: Integer -> List Integer
collatz = (step) => (
  step == 1
    ? [1]
    : [step, ...collatz(collatzStep(step))]
)

I'm open on the indent part, because that can make for nested nested nested ternaries looking extra crazy. (Though usually nested nested nested ternaries are a codesmell)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant