Where we should use throw-catch instead of other elements of ruby like methods, lambdas/procs, return, raise-rescue etc. in a way that we don't mess up our code (for example we don't need to look for catch/throw in other files/classes)? Or to put it into other words, where I can use throw-catch where I cannot (at least easily) use other forms?
For example, this code (from this answer):
catch (:done) do
1.upto(INFINITY) do |i|
1.upto(INFINITY) do |j|
if j>10
throw :done, :done
end
end
end
end
you can write as:
def fun1
1.upto(INFINITY) do |i|
1.upto(INFINITY) do |j|
if j>10
return :done
end
end
end
end
In a Ruby I don't like #2 - catch(:wtf) { throw :wtf } post, author showed that the catch is 4 level deeper than the throw. Later, s/he showed that it can be avoided using simple constructs.
So where is unique usage of throw-catch constructs that make our live easier?