Do you have this question mark? Are you right? I understand it's a question mark because you ask like this
What is the exclamation mark for?
ruby naming-convention method
A method that ends with an exclamation point means, "This method changes the content of the object." It is also called dangerous methods because unexpected things can happen if you are referencing this object elsewhere.
foo = "A STRING"
Foo.downcase! # Turn yourself into a lowercase letter
puts foo
If you look at libaray, you can see that the same name method is divided into two, one with an exclamation point and one without an exclamation point (the one without an exclamation point is called safe methods).
foo = "A STRING"
bar = foo.downcase #foo doesn't change, return
puts foo # prints unchanged foo
puts bar # prints newly created bar
© 2024 OneMinuteCode. All rights reserved.