Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #5090

Re: Method that mutates object

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail
From Jeremy Bopp <jeremy@bopp.net>
Newsgroups comp.lang.ruby
Subject Re: Method that mutates object
Date Thu, 26 May 2011 09:43:17 -0500
Organization Service de news de lacave.net
Lines 28
Message-ID <4DDE6703.1060909@bopp.net> (permalink)
References <9004f010954dd5cee76c02c11f61ad58@ruby-forum.com> <83f24a3dcb1393dc972a306e2d05d5ed@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 1306421024 98310 65.111.164.187 (26 May 2011 14:43:44 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Thu, 26 May 2011 14:43:44 +0000 (UTC)
In-Reply-To <83f24a3dcb1393dc972a306e2d05d5ed@ruby-forum.com>
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 383804
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <4DDE6703.1060909@bopp.net>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:5090

Show key headers only | View raw


On 5/26/2011 08:56, jay s. wrote:
> Say we wanted to write our own replace method and not use the replace
> method provided by the String class?  So we want to write a method that
> takes a string object and modifies/mutates that same object and then
> returns it, without creating a copy of that object.

What exactly are you trying to accomplish?  The String class provides
multiple methods to mutate the String instance in various ways, and many
of those methods could be specified in terms of the others, including
replace.  Rather than ask someone to figure out another solution to
which you may respond, "and how do we write our own method_x and not use
the method_x provided by the String class," could you provide some
details about your goals?  What kind of modifications on the String
instance do you want your method to perform?  What methods provided by
the String class are out of bounds (as replace apparently is)?

To me this is sounding a bit like a homework assignment, but maybe it's
not.  In any case, the documentation for the String class is actually
pretty good, so you can probably answer your own question with a little
easy reading:

http://rdoc.info/stdlib/core/1.9.2/String

If I understand what you're really trying to accomplish, the method you
want is definitely listed there.

-Jeremy

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Method that mutates object jason solomon <solomon.jas@gmail.com> - 2011-05-25 14:22 -0500
  Re: Method that mutates object Stefano Crocco <stefano.crocco@alice.it> - 2011-05-25 14:28 -0500
    Re: Method that mutates object jason solomon <solomon.jas@gmail.com> - 2011-05-25 15:52 -0500
  Re: Method that mutates object Adam Prescott <adam@aprescott.com> - 2011-05-25 14:31 -0500
  Re: Method that mutates object Quintus <sutniuq@gmx.net> - 2011-05-25 15:45 -0500
    Re: Method that mutates object jason solomon <solomon.jas@gmail.com> - 2011-05-25 16:03 -0500
  Re: Method that mutates object jason solomon <solomon.jas@gmail.com> - 2011-05-25 15:59 -0500
    Re: Method that mutates object Brian Candler <b.candler@pobox.com> - 2011-05-25 16:20 -0500
  Re: Method that mutates object "jay s." <solomon.jas@gmail.com> - 2011-05-25 16:36 -0500
    Re: Method that mutates object 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-25 17:00 -0500
  Re: Method that mutates object "jay s." <solomon.jas@gmail.com> - 2011-05-26 08:56 -0500
    Re: Method that mutates object Jeremy Bopp <jeremy@bopp.net> - 2011-05-26 09:43 -0500
      Re: Method that mutates object "jay s." <solomon.jas@gmail.com> - 2011-05-26 10:00 -0500
        Re: Method that mutates object Josh Cheek <josh.cheek@gmail.com> - 2011-05-26 13:12 -0500
  Re: Method that mutates object "jay s." <solomon.jas@gmail.com> - 2011-05-26 10:55 -0500
  Re: Method that mutates object "jay s." <solomon.jas@gmail.com> - 2011-05-26 11:07 -0500
    Re: Method that mutates object Jeremy Bopp <jeremy@bopp.net> - 2011-05-26 11:14 -0500
      Re: Method that mutates object "jay s." <solomon.jas@gmail.com> - 2011-05-26 11:30 -0500
    Re: Method that mutates object Gary Wright <gwtmp01@mac.com> - 2011-05-26 16:34 -0500
      Re: Method that mutates object Adam Prescott <adam@aprescott.com> - 2011-05-27 10:57 -0500
      Re: Method that mutates object Christopher Dicely <cmdicely@gmail.com> - 2011-05-28 13:05 -0500
        Re: Method that mutates object Gary Wright <gwtmp01@mac.com> - 2011-05-28 19:29 -0500
          Re: Method that mutates object Gary Wright <gwtmp01@mac.com> - 2011-05-28 21:06 -0500

csiph-web