The 'dangerous' aspect is more generally accurate than mutation for this convention but at some point we had nearly converged on the idea that it only makes sense to use ! If there is a non-bang version.
That's still what I do.
What are core examples where that's not the case?
That's still what I do.
What are core examples where that's not the case?
Comments
The convention as best as I know it is that a bang method is the more dangerous version of a method with the same name without the bang.
This is true for exit/exit!
But Piotr mentioned that there were methods in core without a corresponding non-bang version...
That said… 😇
Now I wonder what percentage of all the bang methods in Ruby that represents...
(I actually think looking at core Ruby to figure out what's canon is not the way, but as an empirical observation it's interesting!)
https://github.com/ruby/rbs?tab=readme-ov-file#rbs
(In that case the mutation is why it's "more dangerous")
It's only when you have things like sort / sort! that it matters as far as mutability goes.