3 ms·
Methods in ruby only have the bang if there's another version of the method and this one might surprise you. Push and pop don't have it because they mutate the
by 8fGTBjZxBcHq 10y ago
Methods in ruby only have the bang if there's another version of the method and this one might surprise you.
Push and pop don't have it because they mutate the array like they do in almost every non-hardcore-functional language, so that's the expected behavior.
Things like map! and reject! have them because there _is_ another version, and _this_ one might bite you. It has nothing to do with side-effects or immutability per se, that's just the most common case.