From: Paul A. on
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.
--
Posted via http://www.ruby-forum.com/.

From: David A. Black on
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


David

--
David A. Black, Senior Developer, Cyrus Innovation Inc.

From: Paul A. on
Nice article, David. Thank you.
--
Posted via http://www.ruby-forum.com/.