# Re: str1 = str2 is not a copy?!?

**URL:** <https://www.ruby-forum.com/t/re-str1-str2-is-not-a-copy/74787>\
**Category:** Ruby\
**Created:** [November 7, 2006, 10:56am UTC](https://www.ruby-forum.com/t/re-str1-str2-is-not-a-copy/74787 "2006-11-07T10:56:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [November 7, 2006, 10:56am UTC](https://www.ruby-forum.com/t/re-str1-str2-is-not-a-copy/74787/1 "2006-11-07T10:56:24Z")

</div>

From: Austin Z. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

> > BTW, is there a foreach function that automatically strips off the  
> > newlines from line? Returning the record separators is silly.
> 
> No, it isn’t silly. Sometimes, that’s what people want. You should be  
> using #chomp or #chomp! to strip that (use #strip or #strip!  
> if and only if you want to remove whitespace from beginning and end of  
> the line).

I would argue that this claim is subjective. I personally feel that it  
is silly, akin to if String#split left the delimiters at the end of each  
match.

(And there’s one answer, Joe. If you can handle slurping the whole file  
into memory, perhaps instead use something like:  
IO.read( data\_file ).split( $/ ).each{ |line| … }  
to process your data.)
