Dimitri Aivaliotis wrote:
> Hi Peter,
> 
> On 4/6/06, Peter Bailey <pbailey / bna.com> wrote:
> 
>> I kind of did what you had here, just a bit simpler:
> 
>>         line.gsub(/Microsoft/, "Apple")
> 
> Here's where you need a ! -> that line should read:
> 
>            line.gsub!(/Microsoft/,"Apple")
> 
> (See James' example.)
> 
> The "gsub" will act on "line", and return a new object.  On the other
> hand, the "gsub!" will change the "line" itself, without creating a
> new object.  This is what you want in this case.
> 
> In general, when there's an exclamation point version of a method, it
> will change the object itself, instead of returning a new, changed
> object.
> 
> - Dimitri

Cool. Thanks! So, in James' example, he uses "sub" instead of "gsub." 
Are they the same thing?

-- 
Posted via http://www.ruby-forum.com/.