Hacker News new | ask | show | jobs
by setr 1586 days ago
If the language implements them as lazy iteration, then I think take_until would be effectively equivalent to break, with early exiting behavior.

List.where(…).map(…).take_until(…)

2 comments

> If the language implements them as lazy iteration

JS doesn't, though.

> then I think take_until would be effectively equivalent to break

JS also doesn't have take_until.

>JS also doesn't have take_until.

I just assumed it was a new method coming out soon! Although when I was thinking of how I would make a method I just thought an until method that iterated all elements of an array outputting them until it got the return from the callback that was passed as the iteration stopper - default value null.

maybe, but that seems a weird way to say you can do it.