From: Paul A. on 27 Jun 2010 17:29 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 27 Jun 2010 17:34 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 27 Jun 2010 17:52 Nice article, David. Thank you. -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: Convert \uXXXX to character Next: how i execute a method variable numer of times |