# About method naming convention with "!"

**URL:** <https://www.ruby-forum.com/t/about-method-naming-convention-with/190784>\
**Category:** Ruby\
**Created:** [June 27, 2010, 11:29pm UTC](https://www.ruby-forum.com/t/about-method-naming-convention-with/190784 "2010-06-27T23:29:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![judge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@judge](https://www.ruby-forum.com/u/judge)\
**Post date:** [June 27, 2010, 11:29pm UTC](https://www.ruby-forum.com/t/about-method-naming-convention-with/190784/1 "2010-06-27T23:29:48Z")

</div>

Hi,

Is there a reason why Array#clear method have not a exclamation mark (!)  
at the end? Just like Array#map! because the object is altered (so it’s  
called a dangerous method). In my opinion, Array#clear is an as  
dangerous one that alters its object, and it may be used with the  
exclamation mark…

What do you think about? Thanks for your comments.

---

<div class="post-metadata">

**Author:** ![judge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@judge](https://www.ruby-forum.com/u/judge)\
**Post date:** [June 27, 2010, 11:39pm UTC](https://www.ruby-forum.com/t/about-method-naming-convention-with/190784/2 "2010-06-27T23:39:48Z")

</div>

Hi –

On Mon, 28 Jun 2010, Paul A. wrote:

> Hi,
> 
> Is there a reason why Array#clear method have not a exclamation mark (!)  
> at the end? Just like Array#map! because the object is altered (so it’s  
> called a dangerous method). In my opinion, Array#clear is an as  
> dangerous one that alters its object, and it may be used with the  
> exclamation mark…
> 
> What do you think about? Thanks for your comments.

The ! only has meaning when there’s also a non-! method of the same  
name. There’s no general or abstract notion of danger – it’s always  
comparative.

Have a look at:

[http://dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist](http://dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist)

David

---

<div class="post-metadata">

**Author:** ![judge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@judge](https://www.ruby-forum.com/u/judge)\
**Post date:** [June 27, 2010, 11:52pm UTC](https://www.ruby-forum.com/t/about-method-naming-convention-with/190784/3 "2010-06-27T23:52:36Z")

</div>

Nice article, David. Thank you.
