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

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.

主站蜘蛛池模板: 哈尔滨市| 长泰县| 贵定县| 新安县| 曲周县| 瑞昌市| 延津县| 祁连县| 墨竹工卡县| 大余县| 汉川市| 亳州市| 乳山市| 都昌县| 呼图壁县| 辰溪县| 绥江县| 五台县| 海南省| 德清县| 新安县| 靖安县| 玛曲县| 雷山县| 宣武区| 会宁县| 什邡市| 攀枝花市| 栾川县| 阳江市| 万荣县| 米林县| 黑河市| 策勒县| 萨迦县| 灌阳县| 潮安县| 绥宁县| 禄丰县| 容城县| 德保县|