From: jason solomon Newsgroups: comp.lang.ruby Subject: Method that mutates object Date: Wed, 25 May 2011 14:22:46 -0500 Organization: Service de news de lacave.net Lines: 26 Message-ID: <9004f010954dd5cee76c02c11f61ad58@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1306351384 3607 65.111.164.187 (25 May 2011 19:23:04 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Wed, 25 May 2011 19:23:04 +0000 (UTC) X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 383760 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <9004f010954dd5cee76c02c11f61ad58@ruby-forum.com> Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!feed.ac-versailles.fr!talisker.lacave.net!lacave.net!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:5050 Say we want to write a String method called clear that takes a given string and modifies that string to be equal to "". Ex. str = "string" we call str.clear and we get back "", not just "" printed to the screen, but the value of str is now "" (mutate the original string). I understand that the following code would just print "" to the screen but not modify the actual str object. class String def clear "" end end How would you write a method that actually modifies the str object? -- Posted via http://www.ruby-forum.com/.