Ruby's "Bang" Methods
I’ve known for a while that there are a number of Ruby and Rails methods that use a ! (bang) at the end to modify in-place. Very convenient! What I didn’t know until very recently was how that might affect an object being passed in to another method. Here’s an example:
In 12 years of writing Ruby, I somehow never came across this until yesterday. I knew bang methods modified in-place, but I didn’t realize it modified the object even outside the scope of the function. Lesson? Don’t be me and be cautious when using the ! after a method name.