News for hackers. Stuff that matters.
Re:Read this post ‘unless’ you’re not a Ruby developer by nine_k on Tuesday December 13, 2022 @10:58AM (#33970580)
The `for` is a very ergonomic syntax to mapping a computation to every element of a sequence. The `while` does a really different thing, it's not about sequences at all, but about checking some bit of mutable state repeatedly.
Re:Read this post ‘unless’ you’re not a Ruby developer by shakow on Tuesday December 13, 2022 @11:06AM (#33970714)
> The `for` is a very ergonomic syntax to mapping a computation to every element of a sequence.

The very ergonomic solution to map a computation to every element of a sequence is `map`. In this case, `for` is filled with bookkeeping that does not matter.

Re:Read this post ‘unless’ you’re not a Ruby developer by nine_k on Tuesday December 13, 2022 @02:30PM (#33974420)
I edited out "syntax sugar" that was in the post initially.

Also, the `for` operator definitely predates the `map` function. Some people also prefer `map` to be more or less pure and expect it to return a usable list; `for ` has no such expectation, it e.g. may consist solely in printing elements.

Re:Read this post ‘unless’ you’re not a Ruby developer by shakow on Tuesday December 13, 2022 @07:41PM (#33978460)
> Also, the `for` operator definitely predates the `map` function

And `CAS/Compare Accumulator with Storage` definitely predates `if`, still you are most probably using the latter.