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

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.

主站蜘蛛池模板: 泸定县| 太仓市| 江西省| 海南省| 田阳县| 隆回县| 曲阳县| 乌拉特中旗| 淮阳县| 海盐县| 高陵县| 华池县| 通许县| 额尔古纳市| 贡嘎县| 丹东市| 白玉县| 灌南县| 名山县| 通辽市| 自贡市| 策勒县| 方城县| 高陵县| 阿合奇县| 扬中市| 监利县| 拜城县| 葵青区| 永清县| 烟台市| 余庆县| 南岸区| 铜梁县| 揭阳市| 那坡县| 西和县| 拉孜县| 英山县| 锡林浩特市| 鹿泉市|