From: Chad Perrin Date: 2007-07-13T15:49:56+09:00 Subject: Re: gets On Fri, Jul 13, 2007 at 03:24:30PM +0900, Robert Klemme wrote: > 2007/7/13, Jeffrey Bowen : > >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 > > Use chomp! > > >print "test1 " > >test1 = gets > >puts test1.class > >if test1 == "1" > > puts "step 1" > >else > > puts "step 2" > >end That was the first thing that occurred to me, too, but I think that Chris Carter's solution is (usually) the better option. In-place modification can lead to some difficult-to-track bugs when working with complex code, and can also be problematic for concurrency -- so I try to stay in the habit of avoiding in-place modifications. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] Kent Beck: "I always knew that one day Smalltalk would replace Java. I just didn't know it would be called Ruby."