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

More Iterator methods: slice_before, slice_after, slice_when, chunk_while #7142

Closed
asterite opened this issue Dec 4, 2018 · 5 comments
Closed

Comments

@asterite
Copy link
Member

asterite commented Dec 4, 2018

While coding this year's Advent of Code it would have been nice to have these Iterator methods. They exist in Ruby but are missing in Crystal. They are sometimes useful in this type of problems, where using Crystal is more fun :-P

Is there interest in these? I can submit a PR with a commit for each of these.

I guess the names can remain the same as in Ruby.

@mamantoha
Copy link
Contributor

While coding the fifth day of Advent of Code it would have been nice to have String#swapcase and Char.swapcase methods. Yeah 🙂

@asterite
Copy link
Member Author

asterite commented Dec 5, 2018

@mamantoha Hehe, indeed. At this point, given that swpacase's implementation is trivial, I'd say we could add it just fine.

@yxhuvud
Copy link
Contributor

yxhuvud commented Dec 5, 2018

to_h(&:block) from Ruby 2.6 could be nice to have too, if we are window shopping ruby methods :)

@straight-shoota
Copy link
Member

Please keep in mind though that a time travelling Santa solving elves puzzles is not entirely representing real world use cases.

Just to put some restraints on the shopping spree ;)

@asterite
Copy link
Member Author

asterite commented Dec 7, 2018

This is all done now :-)

(open a separate issue if you'd like swapcase, I'm still not sure it's that useful)

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

4 participants