metarhia / common

Metarhia Common Library 🗜️
https://metarhia.com
MIT License
63 stars 34 forks source link

Implement Iterator#keepLast() to allow storing last iterator value #340

Open lundibundi opened 4 years ago

lundibundi commented 4 years ago
lundibundi commented 4 years ago

I think the proposed splitOn is something like https://github.com/metarhia/common/pull/339.

Will think about a better solution.

Leading to a situation where you have multiple iterators sharing a common state.

Though, what's wrong with this? I think it's already possible if someone wants to take values from the same iterator in multiple places (which is fine IMO) or misuses iterator (like using async function in .map etc).

nechaido commented 4 years ago

Though, what's wrong with this? I think it's already possible if someone wants to take values from the same iterator in multiple places (which is fine IMO) or misuses iterator (like using async function in .map etc).

The problem is that it forces programmers to save iterator pre-transformation. I know that it is currently possible to misuse iterators, but I believe that we should not encourage such patterns.