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

short assignments dont get a new line in case: #471

Merged
merged 1 commit into from
Aug 28, 2024
Merged

short assignments dont get a new line in case: #471

merged 1 commit into from
Aug 28, 2024

Conversation

asibahi
Copy link
Contributor

@asibahi asibahi commented Aug 12, 2024

No description provided.

@DanielGavin
Copy link
Owner

DanielGavin commented Aug 22, 2024

Not sure If I want this to be default. It's a fairly simple thing, so adding a config for it in the branch statement is good enough.

There are issues with consistency when you have one case with simple statements and others with more than one.

switch v {
case .One
    my_value -= 1
    my_value_2 += 2   
case .Two: my_value += 1
case . Three: 
    my_value -= 2
    my_value_2 += 2
}

@DanielGavin DanielGavin merged commit 1c62e7c into DanielGavin:master Aug 28, 2024
5 checks passed
@asibahi asibahi deleted the one_line_case_clause branch August 28, 2024 17:26
@thetarnav
Copy link
Contributor

Maybe it should check if all cases are one-liners
so its either

switch v {
case .One my_value -= 1
case .Two: my_value += 1
case .Three: my_value -= 2
}

or

switch v {
case .One
    my_value -= 1
    my_value_2 += 2
case .Two:
	my_value += 1
case .Three: 
    my_value -= 2
    my_value_2 += 2
}

@DanielGavin
Copy link
Owner

It's more consistent to do either everything or nothing.

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

Successfully merging this pull request may close these issues.

3 participants