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

[RFC] ElseIf #1127

Closed
mwasplund opened this issue Dec 24, 2022 · 4 comments
Closed

[RFC] ElseIf #1127

mwasplund opened this issue Dec 24, 2022 · 4 comments

Comments

@mwasplund
Copy link

Proposal: Add else if/elif to allow for chaining conditionals.

Without a switch or match statement conditionals can easily explode into a spaghetti mess of nested if statements. Else if would allow for a more flat, clean decision tree.

if (value == 1) {
  // Do stuff
} else if (value == 2) {
  // Do other stuff
} else {
  // Default stuff
}
@ruby0x1
Copy link
Member

ruby0x1 commented Dec 24, 2022

This is already supported and always has been, it was added to the docs recently but the auto doc updates aren't hooked up right now.

@ruby0x1 ruby0x1 closed this as completed Dec 24, 2022
@mwasplund
Copy link
Author

Great the hear, then this is a bug in the docs: https://wren.io/control-flow.html

@mwasplund
Copy link
Author

But now that I look at the site markdown in main there is an else if example: https://github.com/wren-lang/wren/blob/main/doc/site/control-flow.markdown#if-statements. Might just need to re-deploy the site.

@ruby0x1
Copy link
Member

ruby0x1 commented Dec 24, 2022

correct! thanks for filing an issue.

the auto doc updates aren't hooked up right now.

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

2 participants