-
Notifications
You must be signed in to change notification settings - Fork 272
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
Add takeWhileInclusive operator #370
Comments
So basically this is a So imagine:
Should include also have effect the other way around? Take:
What about this one?
|
Tricky question... There are 2 possible ways of implementing it. Case A.Closing immediatly after receiving the element that "falses" the condition. Case B.Ignore elements until it finds an element that matches the condition. Then, after finding it, it starts respecting to the case A. Perhaps a boolean parameter to the function could inform what kind of behavior the user wants. Something like that:
You could add our examples to the method documentation. I think it will be great that way :) |
For case B, something like
...which complements Basically if it is an inverted takeWhile, then it should not close when the condition yields true a second time:
|
But if |
No, just as takeWhile stops as soon as the condition fires, ignoreWhile waits until the condition fires. So in both cases, they're 1 time toggles. A where simply filters. Take Stream.fromIterable([1,2,3,1 2 3]) |
Nice. I think this is a good approach. |
Yeah I'll do a PR tomorrow for both, if ignoreWhile is relevant enough, it can join :) |
Sure it is! I can't think in a working example for it right now but I am sure it can be usefull for some situations. |
Consider name |
I agree with @hoc081098! |
As discussed here:
Originally posted by @shinayser in #369 (comment)
The text was updated successfully, but these errors were encountered: