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

Change second argument of str.substring to accept length, not second index #5451

Open
Chriscbr opened this issue Jan 16, 2024 · 2 comments
Open
Labels
✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl 🎨 sdk SDK

Comments

@Chriscbr
Copy link
Contributor

Use Case

Feedback from @eladb and @olivernybroe

Proposed Solution

No response

Implementation Notes

No response

Component

SDK

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.
  • If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Slack.
@Chriscbr Chriscbr added ✨ enhancement New feature or request 🎨 sdk SDK needs-discussion Further discussion is needed prior to impl labels Jan 16, 2024
@monadabot monadabot added this to Wing Jan 16, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Jan 16, 2024
@Chriscbr
Copy link
Contributor Author

Chriscbr commented Jan 16, 2024

I'm not sure if there's a "right" API here. I was curious what other languages do, here's what I found:

Personally I'm okay with either semantics. I've opened a separate issue for a dedicated string slicing syntax (s[3..6]): #5452

@eladb
Copy link
Contributor

eladb commented Jan 16, 2024

Thanks for the research!

Beautifully, JavaScript also has a substr method which accepts index and length, but it's deprecated.

Which makes me think that we should either stick with what we have right now to be compatible with modern JS, rename our method to substr or use keyword arguments to make this explicit:

s.substring(6, len: 2);

But maybe that's too much?

Also, slices ❤️

At any rate- Chris it's your call.

@staycoolcall911 staycoolcall911 moved this from 🆕 New - not properly defined to 🤝 Backlog - handoff to owners in Wing Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl 🎨 sdk SDK
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

2 participants