The following pattern is commonly used to define method names in ruby.
Def method_name (arg1, arg2) # Some codeend
However, it is often seen in the code of books or other authors that=? !These three special weird symbols serve as the suffix of the method name.
"? "It is used to indicate the predicates, that is, the method to return the Boolean value, such as array. Empty? (Determines whether the element in the array is null ).
"!"The exclamation point at the end of the method name indicates that you need to be careful when using this method. Many Ruby core Classes define paired methods. They have the same name, but the end difference is a "!", In general, the method is returned without an exclamation mark.
Call a copy of this method. The method with Two exclamation points is a mutable method that modifies the original object, such as sort and sort in the array class!
"="When you want to set the value of an attribute, directly copying these variables conforms to everyone's general understanding. In Ruby, you can create a method ending with an equal sign to achieve this goal.