Docs call bang methods “dangerous": “the dangerous method implies that...[it] permanently modifies its receiver.” Seems to tightly couple “dangerous” with “mutation,” but could “danger” include other risks, as Piotr and Gregory suggest? Maybe, docs suggest a stronger correlation than was intended.
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.
For ipv6_only! that seems like a weird edge case moreso than an intentional design but not sure about that one!