> Python, C++, Ruby and Java all use exceptions. To them, “exception” means, “nifty piece of syntax kinda like goto.” Not Ruby. In idiomatic Ruby^ exceptions are for exceptional cases, not code flow. "nifty piece of syntax kinda like goto." is the much underused but very powerful catch+throw. Or rather, it's a stack unwinding mechanism: think baseball, the catcher expects a ball, with the ball being a message to be p…
[1]: isinstance(StopIteration, Exception) [1]: False
no, really:
help(StopIteration)
class StopIteration(Exception)
| Signal the end from iterator.__next__().
|
| Method resolution order:
| StopIteration
| Exception
| BaseException
| object
...