------art_24773_24362202.1184366301487
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 7/13/07, John Joyce <dangerwillrobinsondanger / gmail.com> wrote:
>
>
> On Jul 13, 2007, at 8:31 AM, Jeffrey Bowen wrote:
>
> > Thanks
> > Sometime I'm just slow.  I tried
> > "test.chomp  ets" but I didn't try "test > > gets.chomp".  The error message most likely told me
> > what was wrong.
> >
> > Thanks
> > Jeff
> >
> > --- Jeffrey Bowen <ja_bowen / yahoo.com> wrote:
> >
> >> Of course the code below will not work because gets
> >> is
> >> adding /n to the entry.  I know that chomp will
> >> remove
> >> the /n but is there away to cut the /n without
> >> reassigning test1 to another variable IE test2 > >> test1.comp
> >>
> >> print "test1 "
> >> test1  ets
> >> puts test1.class
> >> if test1 "1"
> >>         puts "step 1"
> >> else
> >>         puts "step 2"
> >> end
> >>
> >> Thanks
> >> Jeff
> >>
> test.chomp  ets
>
> and
>
> test  ets.chomp
>
> Will give you different results.
> test.chomp will return a chomped value but doesn't permanently chomp
> the value in test
> you would need to do
>
> test.chomp!  ets


You can't do this. (At least not using that syntax). Furthermore it would
not be able to have the desired semantics anyway.

Your choices are
test1  ets.chomp

OR

test1  ets
test1  est1.chomp

OR

test1  ets
test1.chomp!

OR

test1  ets.chomp! # will work in this case, not a good idea from a best
practices POV

I mighta missed a variation, but you definitely can't do test1.chomp! gets. That's nonsense.

This is the destructive version of chomp, methods ending with !
> usually modify the receiver in place, others usually don't.
> The reason my version doesn't need chomp! is because it takes the
> chomped value of gets and assigns that to test.
>
>
>

------art_24773_24362202.1184366301487--