- Comprehensive Ruby Programming
- Jordan Hudgens
- 141字
- 2021-07-02 21:13:27
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.
推薦閱讀
- Unity 2020 By Example
- 精通Nginx(第2版)
- Objective-C Memory Management Essentials
- Mastering Entity Framework
- SQL for Data Analytics
- MySQL 8 DBA基礎教程
- PyTorch自然語言處理入門與實戰
- Groovy for Domain:specific Languages(Second Edition)
- Functional Programming in JavaScript
- Building Mapping Applications with QGIS
- 面向對象程序設計(Java版)
- 深入淺出Serverless:技術原理與應用實踐
- 第一行代碼 C語言(視頻講解版)
- WildFly Cookbook
- 深入大型數據集:并行與分布化Python代碼