I recently started a discussion about raise vs. throw . There is another stream of SO discussing this issue , and experts described this situation as follows:
- Throw and raise are pretty much interchangeable
- The advantage of
throw is that you can easily drop something and that you donβt waste time collecting stack traces
This leaves me with a question, why is nobody really using a cast in Ruby? The topic discussed earlier mentioned the use of catch / throw in Sinatra to handle HTTP error codes, but, nevertheless, I saw very few examples of catch / throw in the wild, and I used it only once in my own code. As the current Rails security crisis has shown, the Ruby community is widely ignoring important features (SAFE security level in this particular case). So what about the trap / throw?
source share