I think this is just plain incorrect. The example given later in this paragraph is the Rails `update` method--but the approach used in all canonical Rails examples and generators is the non-exception version of `update`.
I think this is just plain incorrect. The example given later in this paragraph is the Rails `update` method--but the approach used in all canonical Rails examples and generators is the non-exception version of `update`.
I'd argue that now Ruby has some kind of pattern matching, it can take the place of using exceptions for control flow. You can just return the class itself instead of raising it, then match on it.
Do you happen to have an example of such control flow to link to? Not that I don't believe you but I wonder if there's a difference in what is meant by "control flow" between commenters.
begin
do_stuff!
rescue MyFirstLibraryError => error
# handle first
rescue MySecondLibraryError => error
# handle second
end
That could be "control flow" to one person and "error handling" to another. Or even both to a third person.It may be true in Python--I don’t use it much--but I know Ruby well. It was my primary language for 13 years, at multiple companies. I taught it to over a thousand engineers at Airbnb over the course of five years. I still disagree that it is common to use exceptions for control flow.
Maybe it’s a matter of the interpretation of the word “common.” ¯\_(ツ)_/¯