Possible Duplicate:
Why are exclamation marks used in Ruby methods?
While looking over some Ruby code I came across this method:
def SomeMethod!
// ...
end
What does the ! following the method name do?
Possible Duplicate:
Why are exclamation marks used in Ruby methods?
While looking over some Ruby code I came across this method:
def SomeMethod!
// ...
end
What does the ! following the method name do?
I believe it's just a convention to mark a method as 'more dangerous than others." This could mean that it has a side effect that affects its parameters or maybe its class attributes. It's just a reminder to be careful.
The exclamation mark at the end of a method's name means that such a method performs an operation in a more dangerous way than the version of the same method without the !
.
Notice that you should never ever use !
if there is not such other method. You can understand !
as a means to visually differentiate between two otherwise equivalent methods.
Example: