Give it a bang!

Before we end this guide, I want to discuss something you may have noticed when it comes to Ruby methods. There are a number of methods that have similar names, with the only difference being that one method will have a ! symbol and the other does not.

The ! symbol is called bang in Ruby. So if you see a method such as my_method!, out loud you'd say my_method bang.

Let's take a look at an example of how bang is used for the upcase method. The main difference between the two methods is that the bang version will permanently change the value of the variable that the string was stored in.

In general, when the ! symbol is used at the end of a method, it means the original value or string is being changed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.156.202