by xorcist · 5y ago · 0 comments
The example here is a good one. The shorter version reads much better and is more obviously right.
I think they are infinitely worse than while loops. (I ran into this specifically with Pandas dataframes/series)
You save 1 or 2 lines and have ambiguity on wherever "each" is.
Maybe static typing solves this, but I've decided I hate syntax sugar and dynamic typing.
It also splits apart two different kinds of criteria. "Has this run ten times" is a different sort of question than "is the error within the given margin" or "does the temperature now read 60 degrees". (At least, if you're intentionally running the thing 10 times. If it's running incidentally so you don't even know if it will run 10 times then it can be the same sort of question, but in that case I'd argue you should use a while loop….)
> You save 1 or 2 lines and have ambiguity on wherever "each" is.
Like the sibling poster, I'm not certain what you mean by this.
What is "each" ?