官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 阳信县| 金平| 兴城市| 三门县| 贵南县| 伊金霍洛旗| 林甸县| 塔城市| 宁化县| 德格县| 太谷县| 合山市| 华坪县| 马龙县| 冷水江市| 保山市| 盐边县| 富川| 合水县| 新宾| 德令哈市| 当阳市| 河北省| 冀州市| 略阳县| 普安县| 韶山市| 贡山| 永福县| 昌邑市| 武邑县| 新竹市| 西华县| 浮山县| 邵东县| 河西区| 宜兴市| 寻乌县| 积石山| 岳西县| 平邑县|