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

elif let statements #3835

Closed
Chriscbr opened this issue Aug 16, 2023 · 3 comments
Closed

elif let statements #3835

Chriscbr opened this issue Aug 16, 2023 · 3 comments
Assignees
Labels
🛠️ compiler Compiler ✨ enhancement New feature or request good first issue Good for newcomers

Comments

@Chriscbr
Copy link
Contributor

Feature Spec

Support if let in the "elif" position:

let x = Json { ghost: "spooky" };
if let y = x.tryAsBool() {
  log("it's a boolean!");
} elif let y = x.tryAsNum() {
  log("it's a number!");
} else {
  log("it's something else!");
}

Use Cases

Checking and unwrapping values without separate if statements

Implementation Notes

No response

Component

Compiler

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@Chriscbr Chriscbr added ✨ enhancement New feature or request 🛠️ compiler Compiler good first issue Good for newcomers labels Aug 16, 2023
@monadabot monadabot added this to Wing Aug 16, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Aug 16, 2023
@MarkMcCulloh
Copy link
Contributor

I think this helps point out the strangeness/inconsistency of having elif instead of else if. I know consistency here would help me personally remember the control flow syntax because it's just logical combinations of three keywords rather than having a fourth one that you use sometimes:

if let y = x.tryAsBool() {
  log("it's a boolean!");
} elif let y = x.tryAsNum() {
  log("it's a number!");
} else {
  log("it's something else!");
}

vs

if let y = x.tryAsBool() {
  log("it's a boolean!");
} else if let y = x.tryAsNum() {
  log("it's a number!");
} else {
  log("it's something else!");
}

@staycoolcall911 staycoolcall911 moved this from 🆕 New - not properly defined to 🤝 Backlog - handoff to owners in Wing Aug 16, 2023
@marciocadev
Copy link
Collaborator

marciocadev commented Aug 18, 2023

🤣🤣🤣🤣 I just finished implementing a branch for this, and now I'm not sure if I should push it.

I will submit the pull request if there are changes in the 'elif' naming; the implementation is already done, there would be few changes to be made

@marciocadev marciocadev self-assigned this Aug 19, 2023
@staycoolcall911
Copy link
Contributor

Done in #3888

@github-project-automation github-project-automation bot moved this from 🤝 Backlog - handoff to owners to ✅ Done in Wing Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ compiler Compiler ✨ enhancement New feature or request good first issue Good for newcomers
Projects
Archived in project
Development

No branches or pull requests

4 participants