From: Gregory Seidman Date: 2006-04-19T06:34:29+09:00 Subject: Re: String#clear James Gray wrote: > On Apr 18, 2006, at 4:06 PM, Joel VanderWerf wrote: > >>> @some_str.replace("") >>> >>> Is there any good reason String can't have a #clear method? >>> >>> James Edward Gray II >> >> $ irb19 >> irb(main):001:0> "foo".clear >> => "" >> irb(main):002:0> RUBY_VERSION >> => "1.9.0" > > Sweet: now I'll move to the obvious follow-up question... Why are > we not adding this to Ruby 1.8.x? For future compatibility: class String instance_method(:clear) rescue def clear replace "" end end > James Edward Gray II --Greg -- Posted via http://www.ruby-forum.com/.